stringEncryptor
public static String stringEncryptor(String secretKey,
String message,
boolean isEncrypt)
StringEncryptor 加解密。
同一个密钥(secretKey)对同一个内容执行加密,生成的密文都是不一样的,但是根据根据这些密文解密成明文都是可以.
1、Jasypt 默认使用 StringEncryptor 来解密全局配置文件中的属性,所以提供密文时,也需要提供 StringEncryptor 加密的密文
2、StringEncryptor 接口有很多的实现类,比如常用的 PooledPBEStringEncryptor
3、setConfig(final PBEConfig config):为对象设置 PBEConfig 配置对象
4、encrypt(final String message):加密内容
5、decrypt(final String encryptedMessage):解密内容
- 参数:
secretKey - :密钥。加/解密必须使用同一个密钥
message - :加/解密的内容
isEncrypt - :true 表示加密、false 表示解密
- 返回:
- 加密后的值