How do I combine the two methods of cryptography, CBC cipher block and Vingenere Chiper [on hold]
- by Bangpe
Code Vingenere
static String encrypt(String text, final String key) {
String res = "";
text = text.toUpperCase();
for (int i = 0, j = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c < 'A' || c > 'Z') continue;
res += (char)((c + key.charAt(j) - 2 * 'A') % 26 + 'A');
j = ++j % key.length();
}
return res;
}
Code CBC Chiper
public CbcBlockCipher( BlockCipher blockCipher )
{
super( blockCipher.keySize(), blockCipher.blockSize() );
this.blockCipher = blockCipher;
iv = new byte[blockSize()];
zeroBlock( iv );
temp = new byte[blockSize()];
}