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.' |
sagor073
commented
Nov 17, 2023
4d07cfd21cb3b4c6c2aedb05456f5299629ea7b6b80a48004d3ef5e06b8d9e25
4d07cfd21cb3b4c6c2aedb05456f5299629ea7b6b80a48004d3ef5e06b8d9e25
I got "azerty"
909c30a3ac10989d33958a3bdd1193b58d217bfd5e4bebbd3c280c7580afd525
Can anyone please decrypt the below given string for me I have tried many ways.
748c46b945efabb18ef1e793b3af886518042522d55121dbf618e9da0816ec5a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment