1. download url
2. 依賴 jar
jasypt-1.9.0.jar
3. 加密
// 預設加密/解密演算法是 pbewithmd5anddes
standardpbestringencryptor encryptor = new standardpbestringencryptor();
encryptor.setpassword(key);
return encryptor.encrypt(text);
# 注意:這裡每次加密得到的密文都是不一樣的;
4. 解密
standardpbestringencryptor encryptor = new standardpbestringencryptor();
encryptor.setpassword(key);
return encryptor.decrypt(ciphertext);
5. 示例**
package org.demo.encrypt;
import org.jasypt.encryption.pbe.standardpbestringencryptor;
public class encryptutils
/*** 加密
* @param text 明文
* @return 密文
*/public static string encrypt(string text)
/*** 解密
* @param ciphertext 密文
* @return 明文
*/public static string decrypt(string ciphertext)
}
使用jasypt加密解密
spring boot 2.1.11.release gradle 4.8 1 在build.gradle匯入jar implementation com.github.ulisesbocchio jasypt spring boot starter 1.18 jasypt.encryptor.pa...
Java加密跟解密
具體事項請直接看 public static final string key md5 md5 public static byte encryp 5 byte input throws exception public static string encryp 5bybase64 byte inp...
java 加密解密演算法
public class cryptogram 金鑰 private static final int key 5 param args public static void main string args char encryptcode cryptogram.encrypt in system...