package com.ruoyi;

import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;

/**
 * packageName com.ruoyi
 *
 * @author wangxy
 * @version JDK 8
 * @className EncFactory
 * @date 2024/2/22
 * @description TODO
 */
public class EncFactory {

    public static void main(String[] args) {
        String securityKey = "NBPLUS"; // 加密秘钥
        String data = "123456"; // 需要加密的字符串

        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPassword(securityKey);
        config.setAlgorithm("PBEWithMD5AndDES");
        config.setPoolSize("1");
        config.setStringOutputType("base64");
        encryptor.setConfig(config);

        System.out.println("ENC("+ encryptor.encrypt(data) +")");
        System.out.println(encryptor.decrypt("jHVcZqOkRvWzZ0UBcqjctdBF+8w8oTUaBws6tE5/gOc="));

    }
}
