ssid-valid-len.py: attempt adding _nomap counting

Ref: #31
This commit is contained in:
Aminda Suomalainen 2021-10-11 10:51:25 +03:00
parent 2665445dd8
commit ef5dd083cb
Signed by: Mikaela
GPG Key ID: DF046339D69EB8C9
1 changed files with 19 additions and 8 deletions

View File

@ -5,15 +5,26 @@ This script asks for a SSID name, counts it and tells whether it's of valid
length length
''' '''
# Request input # Request input or assume "test" on empty.
givenssid = input("Please enter the SSID you are thinking of: ") givenssid = str(input("Please enter the SSID you are thinking of (preferably 26 chars to fit _nomap): ") or "test")
#givenssid = "test_nomap"
# Ensure it's UTF-8 and store the size. E.g. åäö are longer than oao # Ensure it's UTF-8 and store the size. E.g. åäö are longer than oao
# TODO: make this a function too
givenssidlen = len(givenssid.encode("utf8")) givenssidlen = len(givenssid.encode("utf8"))
# 32 bytes should be the maximum SSID length # Checking the SSID length is done twice, so thus a function
if givenssidlen <= 32: def checkssidlen(givenssidlen):
print(givenssid, "is", givenssidlen, "long and thus valid length") # 32 bytes should be the maximum SSID length
else: if givenssidlen <= 32:
print("Too long, try again") print(givenssid, "is", givenssidlen, "long and thus valid length")
else:
print(givenssid, "is", givenssidlen, "to long, please select a different SSID")
# Checking the SSID without _nomap
checkssidlen(givenssidlen)
# TODO: make this a function too
givenssidlen = len(givenssid.encode("utf8"))
# Continuing with _nomap to ensure it also fits
givenssid = givenssid + "_nomap"
checkssidlen(givenssidlen)