.

Saturday, March 10, 2012

[C++] ECB (Electronic Code Book)


          Hello, Reader ^^! Back again with source code. This time is is ECB (Electronic Code Book) which is made using C++. Encryption using ECB is separating plaintext bit into blocks (key). After that, each block each encrypted with the block key. When the plaintext's length is not divideable by the key's length, pad it with all 0s or all 1s or 101010... Now, let's me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 01101

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000



Plaintext(in bits)01011111110101010000
Key per block01011010110101101011
Xor-ed00000101000000111011


The result of encryption is 00000101000000111011
Now, in this one I made, to be able both the key and the plaintext readable, I also pad the key until it is dividable by 8.

Okay, that's all I can say. Thank you for reading ^^!








No comments:

Post a Comment