?? aes.java
字號(hào):
package crypto_milenage ;
import javacard.framework.*;
import javacard.security.* ;
import javacardx.crypto.*;
public class aes
{ private AESKey aeskey;
private Cipher cipherAES ;
public byte [] Out; // = new byte[BLOCK_SIZE];
public aes()
{ Out = JCSystem.makeTransientByteArray((short)(16),JCSystem.CLEAR_ON_DESELECT);
try {
cipherAES = Cipher.getInstance(Cipher.ALG_AES_BLOCK_128_ECB_NOPAD, false); }
catch (CryptoException e){}
try {
aeskey = (AESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_AES,KeyBuilder.LENGTH_AES_128,false);}
catch (CryptoException e){}
}
public void setKey( byte[] key,short off,byte mode )
{
try{ aeskey.setKey(key,off);}
catch (CryptoException e){}
if (mode == (byte)1)
try{cipherAES.init(aeskey, Cipher.MODE_ENCRYPT);}
catch (CryptoException e){}
else
try{cipherAES.init(aeskey, Cipher.MODE_DECRYPT);}
catch (CryptoException e){}
}
/// Encrypt a block.
public void encrypt( byte[] clearText, short clearOff, byte[] cipherText, short cipherOff )
{
try{cipherAES.doFinal(clearText,clearOff,(short)16,cipherText,cipherOff);}
catch (CryptoException e){}
}
} // aes
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -