-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Encrypting a whole string with variable length needs splitting it into buffers of 16 characters. The encrypted result consists of each buffer, which has to be encrypted separately.
for(int block=0; block < plainText.length()/BUFF_SIZE; block++) {
for(int j = block*BUFF_SIZE; j < (block+1)*BUFF_SIZE; j++) {
buffer += plainText[j];
}
cipherTextString += encryptBuffer(const_cast<char*>(buffer.c_str()), key);
buffer = "";
}
buffer="";
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];
};
cipherTextString += encryptBuffer(const_cast<char*>(buffer.c_str()), key);
}
return cipherTextString;```
Metadata
Metadata
Assignees
Labels
No labels