-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
It seems like the char after NULL(\0) are filled with random values. This means there will be error when decrypting using the online tools e.g. Calculator
According to Using Padding in Encryption
We need to pad the block with padding bytes to make it up to the required length. There are at least five common conventions:-
Pad with bytes all of the same value as the number of padding bytes
Pad with 0x80 followed by zero bytes
Pad with zeroes except make the last byte equal to the number of padding bytes
Pad with zero (null) characters
Pad with space characters
Could consider adding this code at line 155
if( plainText.length()%BUFF_SIZE > 0 ) {
for(int bytes_read=(index*BUFF_SIZE); bytes_read <= (index*BUFF_SIZE) + plainText.length()%BUFF_SIZE; bytes_read++) {
buffer += plainText[bytes_read];
};
////ADDITIONAL CODE////
int no_to_pad = 16 - buffer.length();
while (buffer.length() < 16) {
char padding = no_to_pad;
buffer += padding;
}
////////////////////////
cipherTextString += encryptBuffer(const_cast<char*>(buffer.c_str()), key);
}Metadata
Metadata
Assignees
Labels
No labels