1. Download URL
Http://www.jasypt.org/download.html
2. Rely on Jar
Jasypt-1.9.0.jar
3. Encryption
The default encryption/decryption algorithm is pbewithmd5anddes
standardpbestringencryptor encryptor = new Standardpbestringencryptor ();
Encryptor.setpassword (KEY);
return Encryptor.encrypt (text);
# Note: Every time you encrypt the ciphertext is not the same;
4. Decryption
Standardpbestringencryptor encryptor = new Standardpbestringencryptor ();
Encryptor.setpassword (KEY);
return Encryptor.decrypt (ciphertext);
5. Sample Code
Package org.demo.encrypt;
Import Org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
public class Encryptutils {//Key private static final String key = "1234567a?"; public static void Main (string[] args) {string ciphertext1 = Encrypt ("ABCDEFG");//wu11fsc0gpgset5au8gxua== String C IPHERTEXT2 = Encrypt ("ABCDEFG");
esxlhsvk2ym7mgchy2ccgg== System.out.println (CIPHERTEXT1);
System.out.println (CIPHERTEXT2);
String Text1 = Decrypt (CIPHERTEXT1);
String Text2 = Decrypt (CIPHERTEXT2); System.out.println (Text1); ABCDEFG System.out.println (TEXT2); ABCDEFG}/** * Encryption * @param text Clear * @return redaction */public static string encrypt (String text) {Stan
Dardpbestringencryptor encryptor = new Standardpbestringencryptor ();
Encryptor.setpassword (KEY);
return Encryptor.encrypt (text);
/** * decryption * @param ciphertext ciphertext * @return plaintext/public static string decrypt (String ciphertext) { StandardpBestringencryptor encryptor = new Standardpbestringencryptor ();
Encryptor.setpassword (KEY);
return Encryptor.decrypt (ciphertext); }
}