Last active
April 17, 2025 00:56
-
-
Save atoponce/af8581397315dfbee490 to your computer and use it in GitHub Desktop.
Encryption and decryption with SHA-256
This file contains hidden or 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.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can anyone please decrypt the below given string for me I have tried many ways.
748c46b945efabb18ef1e793b3af886518042522d55121dbf618e9da0816ec5a