pastebin

Paste Search Dynamic
Recent pastes
generate secret
  1. # your code goes here
  2. import codecs
  3. import string
  4. import sys
  5. import time
  6.  
  7. from cryptography.hazmat.backends import default_backend
  8. from cryptography.hazmat.primitives.hashes import SHA1
  9. from cryptography.hazmat.primitives.twofactor.totp import TOTP
  10.  
  11.  
  12. ONE_WEEK_IN_SECONDS = 604_800
  13.  
  14.  
  15. def generate_secret():
  16.     totp = TOTP(
  17.         key=codecs.encode(string.ascii_letters, encoding="utf-8"),
  18.         length=8,
  19.         algorithm=SHA1(),
  20.         time_step=ONE_WEEK_IN_SECONDS,
  21.         backend=default_backend(),
  22.     )
  23.     seed = int(time.time())
  24.     token = codecs.decode(totp.generate(seed), encoding="utf-8")
  25.     return f"{token}-{seed}"
  26.  
  27.  
  28. if __name__ == "__main__":
  29.     sys.stdout.write(
  30.         f"Please head to https://r...content-available-to-author-only...p.com/careers and use this secret when "
  31.         f"you apply: {generate_secret()}n"
  32.     )
  33.  
  34.  
  35.  
Parsed in 0.015 seconds