|
byte[] abyKey = "key".getBytes();
byte[] abyMsg = "PlainTextMsg".getBytes();
BlockCipher engine = new AESEngine();
BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(engine));
KeyParameter oKeyParameter = new KeyParameter(abyKey);
byte[] abyOut = new byte[ cipher.getOutputSize(abyMsg.length) ];
cipher.init(true, oKeyParameter);
int outputLen = cipher.processBytes(abyMsg, 0, abyMsg.length, abyOut, 0);
try
{
cipher.doFinal(abyOut, outputLen);
}
catch(Exception ex)
{
}
上面的code都能成功encrypt.但是却会出问题当the length of abyMsg 是 16 的倍数。
有人能帮我吗? |
|