Skip to content

Instantly share code, notes, and snippets.

@apostoloss
Last active October 2, 2021 19:22
Show Gist options
  • Save apostoloss/4d18858b0f97d701bac5db1f7007a451 to your computer and use it in GitHub Desktop.
Save apostoloss/4d18858b0f97d701bac5db1f7007a451 to your computer and use it in GitHub Desktop.
small function to check if a string is yubikey or not just based on length and if all chars are in the modhex
def isYubikey(string):
"""
Checks if a string looks like a yubikey.
Yubikey strings are exactly 44 characters and use modhex
"""
modhex = "cbdefghijklnrtuv"
if len(string) != 44:
return False
for i in string:
if i not in modhex:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment