我想encript一个字节数组下面是mycode的它工作正常,但 使长尺寸的输出newByteArray我想outputed阵列应该 是大小图16是有可能如何trucate的encripted数组大小16 AES encreption在java中
byte [] keyForEncription= new byte[16];
byte [] keyForDecription= new byte[16];
long FixedKey= 81985526925837671L;
long VariableKey=744818830;
for (int i1 = 0; i1 < 8; i1++)
{
keyForEncription[i1] = (byte)(FixedKey >> (8 * i1));
keyForEncription[i1 + 8] = (byte)(VariableKey >> (8 * i1));
}
byte[] data = new byte[255];
data[0]= 2;
data[1]= 0;
data[2]= 0;
data[3]= 0;
data[4]= 0;
data[5]= 6;
data[6]= 6;
data[7]= 81;
data[8]= 124;
data[9]= 123;
data[10]= 123;
data[11]= 12;
data[12]= 3;
data[13]= 27;
data[15]= 12;
data[16]= 0;
data[17]= 0;
data[18]= 0;
data[19]= 0;
System.out.println("Original byte Array : " +Arrays.toString(data));
SecretKeySpec skeySpec = new SecretKeySpec(keyForEncription, "AES");
Cipher cipher1 = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] newByteArray = new byte[data.length];
newByteArray = cipher.doFinal(byteArray);
System.out.println("Encrypted Array : " +Arrays.toString(newByteArray));
这里是输出加密阵列:[110,-118,-119,-88,73,-118, 57,图15,-52,-78, 100,104,102,-42,-102,-45,-50,-116,-47,-53, 103,-40,-61,6 2,42,15,-124,98,-28,-77,94,78,-50,-116,-47, -53,103,-40,-61,62,42,15,-124 ,98,-28,-77,94,78,-50,-116,-47,-53,103,-40,-61,62,42,15,-124,98,-28,-77, 94,78,-50,-116,-47,-53,103,-40,-61,62,42,15,-124,98,-28,-77,94,78,-50,-116 ,-47,-53,103,-40,-61,62,42,15,-124,98,-28,-77,94,78]
CFB的ECB?你的问题说欧洲央行,你的代码说CFB。 – 2013-03-15 10:36:37
要设置ECB – Jivan 2013-03-15 10:39:44