Jasypt加解密

package com.xingyi.bos.utils;

import com.xingyi.bos.ZjBosApplication;
import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * Created by Administrator on 2021/9/2.
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ZjBosApplication.class})
public class JasyptApplicationTests {
    @Autowired
    private StringEncryptor stringEncryptor;

    @Test
    public void contextLoads() {
        //加密方法
//        System.out.println(stringEncryptor.encrypt("123456"));
//        System.out.println(stringEncryptor.encrypt("123456"));

        //解密方法 ENC(c/Y2PZMYWlFjx7IbNCt8rhsuwLYVWhMI)中的c/Y2PZMYWlFjx7IbNCt8rhsuwLYVWhMI
        System.out.println(stringEncryptor.decrypt("H+u9Bhik38B+UdPZDMLz/BXksIb3KplomVWN/JvQOZI="));
    }

    /*
    4n8hBnSULbLF5FJrC/kMxA==
    MWzRCtyFK0AXpH6g99GOTA==
    RXy31IPONj1nwV01P0+TaA==
    a6EH3950mQYTHtWAop6wDw==
     */
}
原文地址:https://www.cnblogs.com/super-chao/p/15241942.html