fork download
  1. from hashlib import sha256
  2. import string
  3.  
  4. template = """apiVersion: v1
  5. kind: Secret
  6. metadata:
  7. name: my-cool-secret
  8. type: Opaque
  9. stringData:
  10. {}"""
  11.  
  12. secret_hash = "2f97f7393a589fff32db98e5edf54a455937516f567b0d352556537fcb06aa53"
  13.  
  14. def pass_generator(max_length, charset):
  15. for i in range(len(charset)**max_length):
  16. yield get_pass(i, charset)
  17.  
  18. def get_pass(num, charset):
  19. password = ""
  20. while num > len(charset) - 1:
  21. num, index = divmod(num, len(charset))
  22. password += charset[index]
  23. password += charset[num]
  24. return password
  25.  
  26. for password in pass_generator(4, string.ascii_lowercase):
  27. if sha256(template.format(password).encode()).hexdigest() == secret_hash:
  28. print(password)
Success #stdin #stdout 1.83s 11640KB
stdin
Standard input is empty
stdout
bad