Understanding the Need for and Uses of Cryptography
September 9, 2024
Key Questions: What are the trade-offs between different types of keys? Ways to balance security, privacy, and performance? How?
Key Insight: Cryptographic algorithms underpin many of the applications that we use on a daily basis! Let’s try to program them for better understanding! Start by revisiting basics from last week!
cryptography.fernet
to encrypt a string and record
encrypt_string
encrypted_data
byte-encoded stringkey
as a byte-encoded stringKey: b'kf_f0pjz7Tk5p8hjLO0VTsd9M9hzq7GEOqhcloe-7mA='
Encrypted Data: b'gAAAAABoYUSrSiwePuSl5-CjTUFHoSK0Nli-EQSYPOZoqnlv5CFY-JahA4LYeC4dE0C2S0-g5ALl22FfF-9tdC4a3hgDKrlWE1_KjZwIJkTsJR9wQZMB4Aw='
Fernet
key look like?Fernet
key?Fernet
key does not match?b
prefix?key
’s contents?717ac506950da0ccb6404cdd5e7591f72018a20cbca27c8a423e9c9e5626ac61
Encrypted Data: b"\x8f\x0c\x86D9\x97\xacW<\xf3J\xd0X\xc5\xf7\xb1\xc2\x07\xc4+\xb8\xf2M\xe7\xd3q\xd6\xe5\xe7\x111\xd0\x8fc4S\x8a\x8b\xa5\xff\x93\xb1\xad\x86\xe2;\xab\xb4.\x1f\xd9K\xea\x0b\x1c\xec1J\xe1\xc0s\xd0\xda\xc3\x16e>\x00\xaf%B6\x8c\xe0\xd5\xbaEx\xb6\xfa\x1cO\xbe\t\xd6\xf7\x0c\xfaG\x13F\xe0U\x0b\xf3\x10\xad\rdt\x1f6M\x0ee\xc5 \x16\x07d\xfd\x04\x98\x10\x16?\xc1\x9c\xbfd\xd4\xa1\xb6\xfd;\n\xa0\x82\x84\x81~\xf3\xbeDGft4P\x84\x8c\xc2r+!\x10ih\xfa\xe6\r\x1c\xb0\x9a\x8cEz\x9c\n\xd8c\xf7\xb8^\x8d\x94M<\xc3L\x03\xde U\xda^\xba&}\xbb\t.\x07\x12B\xf2\xde\xf3\xf8\x12X}\xd8q\x89j\xf1\xf1\x13D\xd2c\x87`\xe3\xf4\xe9\xf8\x97\x83\xc0\xff\xda#nB-l|H(\x9e\xd8\x0c\xba\xee\x17s0\xaej\xf8\x8b\x04\xc6\x1b\xeb1\x87\\\xb0\xad\xf4\x1f\xd9\x7fw'\x98\xa1\xab&\xb7Sig"
ciphertext_input_asym
!ciphertext
must have the correct length and formatrsa
private key look like?key_size
affect the rsa
algorithm?padding.PKCS1v15()
?rsa
keys incorrectly?Security Synapse