public byte[] encrypt(byte[] buf);
public String encryptToBase64(byte[] buf);
public String encryptToHex(byte[] buf);
public byte[] decryptFromBase64(String encryptedData);
public byte[] decryptFromHex(String encryptedData);
hash api
public String digestToBase64(byte[] data) throws NoSuchAlgorithmException ;
public String digestToHex(byte[] data) throws NoSuchAlgorithmException ;
public byte[] digest(byte[] data) throws NoSuchAlgorithmException ;
use case
crypto
/*** if you want use no_padding in des, you plainText should be n*64 bit; * in aes you should make sure you data be n*128bit* @see studio.guoliao.crypto.constant.PaddingEnum* */publicclassTest{
publicstaticvoidmain(String[] args){
Stringplain = "helloworld";
studio.guoliao.crypto.util.KeyUtilkeyUtil = newstudio.guoliao.crypto.util.KeyUtil();
SecretKeykey = keyUtil.generateRandomKey(KeyDescription.DES_56);
ECBCryptocrypto = newECBCrypto(PaddingEnum.P5_PADDING);
byte[] encrypted = crypto.encrypt(key, plain);
byte[] tmp = crypto.decrypt(key, encrypted);
//...byte[] iv = "".getBytes();
CBCCryptocrypto = newCBCCrypto(PaddingEnum.P5_PADDING, iv);
byte[] encrypted = crypto.encrypt(key, plain);
byte[] val = crypto.encrypt(key, encrypted);
}
}