Skip to content

Instantly share code, notes, and snippets.

@zerlgi
Forked from stealthcopter/talktalk_wps_pin_calc.py
Last active August 29, 2015 14:19
Show Gist options
  • Save zerlgi/9484219db341c5031f6e to your computer and use it in GitHub Desktop.
Save zerlgi/9484219db341c5031f6e to your computer and use it in GitHub Desktop.
# Function to calculate the WPS checksum of a 7 digit number
def wps_checksum(pin):
accum = 0
while pin>0:
accum += 3 * (pin % 10);
pin /= 10;
accum += pin % 10;
pin /= 10;
return (10 - accum % 10) % 10
# Enter the wifi essid string here
essid_string = "TALKTALK-33A3C0"
print "Essid: "+essid_string
# Remove the useless part of essid if it's present
if ("TALKTALK-" in essid_string):
essid_string = essid_string.replace("TALKTALK-","")
# Convert hex string to decimal and ensure it's only 7 digits
essid_dec = int(essid_string, 16) % 10000000
# Calculate the checksum digit and print pin
print "WPS Pin: %07d%d" % (essid_dec,wps_checksum(essid_dec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment