1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| class JasyptDemo { public static void main(String[] args) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setAlgorithm("PBEWithMD5AndDES"); encryptor.setPassword("abc123qwer1113543"); encryptor.setIvGenerator(new RandomIvGenerator()); encryptor.setSaltGenerator(new RandomSaltGenerator()); encryptor.setStringOutputType("hexadecimal"); String encryptText = encryptor.encrypt("123456"); log.info("加密: {}", encryptText); String decryptText = encryptor.decrypt(encryptText); log.info("解密: {}", decryptText); } }
# 加密: 5E8A4A737ECD564CD00DAF5E88FEA28662C32943C34065D9 # 解密: 123456
|