Cipher Block Chaining Mode - Applied Cryptography
Why Stack Overflow recommends it
Stack Overflow users link it as a quick reference when answering or asking about implementing or using CBC mode in code.
Recommended by 1 people across 1 different months, 2013 to 2017.
What it is
A short Udacity clip from the Applied Cryptography course (CS387) that explains how Cipher Block Chaining (CBC) mode works for block ciphers. It covers the idea of chaining each block's encryption to the previous ciphertext block, in under two minutes.
What people said
Recommends Adam · 2017-11 · Stack Overflow · on “Caesar in CBC / How to XOR in Java?”
Hmm I interpret your question like you think you want to xor by the key to your cipher, this is wrong: You xor by the previous result from the cipher. Something like this: // Untested code // The code below need to be adjusted for it to print meaningful // characters in the encrypted string as the xor function produces // integers outside the range of standard ascii characters private void cbcCaesar(){ int key = 1; String message = "java"; int initialisationVector = 5; // the IV is not super necessarily hidden from an attacker but should be different for each message StringBuilder encryptedMessageBuilder = new StringBuilder(); char[] charArray = message.toCharArray(); int encryptedLetter = i
Cites charmoniumQ · 2013-08 · Stack Overflow · on “Protecting a Save file from modification in a game?”
It sounds like you need a cryptography library. This will help you encrypt or decrypt a file using a key. Good thing there is already one called PyCrypto. You can download it here [LINK] . To use it, once you have downloaded it It is documented here [LINK] : import string from Crypto.Cipher import AES from Crypto import Random from Crypto.Random import random def gen_cipher(): # generates 32 letter long key key = ''.join(random.sample(string.ascii_letters, 32)) iv = Random.new().read(AES.block_size) cipher = AES.new(key, AES.MODE_CFB, iv) return cipher, iv def write_data(data, rfile, cipher, iv): with open(rfile, 'w') as f: msg = iv + cipher.encrypt(b'Users cant edit this') f.write(msg) def
Cites c00000fd · 2015-01 · Stack Overflow · on “PHP method to perform AES encryption block-by-block to conserve memory usage”
Let me explain my dilemma. In my PHP script I need to be able to encrypt files uploaded to my site. I chose to use AES-256 [LINK] encryption with CBC ( Cipher-block chaining [LINK] ) mode of operation. Initially I discovered a very promising function that could do this, that would've worked like this: //Just the encryption part $fileData = file_get_contents($serverFilePath); $encData = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $binKey, $fileData, MCRYPT_MODE_CBC, $binIV); The method above works well, except one major issue: I host my site on a shared hosting account and as you see the mcrypt_encrypt method requires the data to be fed into it all at once as a binary string . That becomes an issue i