java 加解密

加解密,需要的jar包:jce.jar,liferay.jar
DESKeySpec dks = new DESKeySpec(bytes[]);
SecretKeyFactory keyFac = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFac.generateSecret(dks);
String result1 = Encryptor.encrypt(key,str);//加密str
String result2 = Encryptor.decrypt(key,str);//解密str

你可能感兴趣的:(java)