Last active
July 6, 2024 23:34
-
-
Save atoponce/af8581397315dfbee490 to your computer and use it in GitHub Desktop.
Encryption and decryption with SHA-256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import hashlib | |
nonce = 0 | |
key = 'f3q4uszyt67cfatq' | |
pad = hashlib.sha256(str(nonce)+key).digest() | |
# encrypt | |
plaintext = 'the quick brown fox jumped over.' | |
ciphertext = '' | |
for i in range(32): | |
ciphertext += chr(ord(pad[i])^ord(plaintext[i])) | |
# ciphertext = '\x1bf\x13\r\x0c\xc4\x18`\x129\x16\x12|\x96\xa7\xc2\xf5E_\x97\xc2\x010\x88]j\xce\xe3x\x14\xe8\xb6' | |
# decrypt | |
plaintext = '' | |
for i in range(32): | |
plaintext += chr(ord(pad[i]^ord(ciphertext[i])) | |
# plaintext = 'the quick brown fox jumped over.' |
sagor073
commented
Nov 17, 2023
4d07cfd21cb3b4c6c2aedb05456f5299629ea7b6b80a48004d3ef5e06b8d9e25
4d07cfd21cb3b4c6c2aedb05456f5299629ea7b6b80a48004d3ef5e06b8d9e25
I got "azerty"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment