2021-10-11 09:39:36 +02:00
|
|
|
#!/usr/bin/env python3
|
2023-05-18 09:06:16 +02:00
|
|
|
"""
|
2021-10-11 09:39:36 +02:00
|
|
|
This script asks for a SSID name, counts it and tells whether it's of valid
|
|
|
|
length
|
2023-05-18 09:06:16 +02:00
|
|
|
"""
|
2021-10-11 09:51:25 +02:00
|
|
|
# Request input or assume "test" on empty.
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSID = str(
|
2023-05-18 09:06:16 +02:00
|
|
|
input(
|
2023-10-10 09:16:58 +02:00
|
|
|
"Please enter the SSID you are thinking of (preferably 26 chars to fit _nomap): ",
|
2023-05-18 09:06:16 +02:00
|
|
|
)
|
2023-10-10 09:16:58 +02:00
|
|
|
or "test",
|
2023-05-18 09:06:16 +02:00
|
|
|
)
|
2021-10-11 09:39:36 +02:00
|
|
|
|
|
|
|
# Ensure it's UTF-8 and store the size. E.g. åäö are longer than oao
|
2021-10-11 09:51:25 +02:00
|
|
|
# TODO: make this a function too
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSIDLEN = len(GIVENSSID.encode("utf8"))
|
2021-10-11 09:39:36 +02:00
|
|
|
|
2023-05-18 09:06:16 +02:00
|
|
|
|
2021-10-11 09:51:25 +02:00
|
|
|
# Checking the SSID length is done twice, so thus a function
|
2023-10-31 09:28:59 +01:00
|
|
|
def checkssidlen(GIVENSSIDLEN):
|
|
|
|
"""
|
|
|
|
This function checks that the given string is below 32 characters long and
|
|
|
|
can thus be used as an SSID.
|
|
|
|
"""
|
2021-10-11 09:51:25 +02:00
|
|
|
# 32 bytes should be the maximum SSID length
|
2023-10-31 09:28:59 +01:00
|
|
|
if GIVENSSIDLEN <= 32:
|
|
|
|
print(GIVENSSID, "is", GIVENSSIDLEN, "long and thus valid length")
|
2021-10-11 09:51:25 +02:00
|
|
|
else:
|
2023-10-17 06:34:05 +02:00
|
|
|
print(
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSID,
|
2023-10-17 06:34:05 +02:00
|
|
|
"is",
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSIDLEN,
|
2023-10-17 06:34:05 +02:00
|
|
|
"to long, please select a different SSID",
|
|
|
|
)
|
2021-10-11 09:51:25 +02:00
|
|
|
|
2023-05-18 09:06:16 +02:00
|
|
|
|
2021-10-11 09:51:25 +02:00
|
|
|
# Checking the SSID without _nomap
|
2023-10-31 09:28:59 +01:00
|
|
|
checkssidlen(GIVENSSIDLEN)
|
2021-10-11 09:51:25 +02:00
|
|
|
# TODO: make this a function too
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSIDLEN = len(GIVENSSID.encode("utf8"))
|
2021-10-11 09:51:25 +02:00
|
|
|
|
|
|
|
# Continuing with _nomap to ensure it also fits
|
2023-10-31 09:28:59 +01:00
|
|
|
GIVENSSID = GIVENSSID + "_nomap"
|
|
|
|
checkssidlen(GIVENSSIDLEN)
|