All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dennisit.vplus.data.utils.JasyptUtils Maven / Gradle / Ivy

There is a newer version: 2.0.8
Show newest version
package com.github.dennisit.vplus.data.utils;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;

public class JasyptUtils {


    /**
     * 编码 默认算法为"PBEWithMD5AndDES"
     *
     * @param keyt   秘钥
     * @param source 原始数据
     * @return 这里每次加密后的密文结果都不一样
     */
    public static String encrypt(String keyt, String source) {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setPassword(keyt);
        encryptor.setAlgorithm("PBEWithMD5AndDES");
        return encryptor.encrypt(source);
    }

    /**
     * 解码 默认算法为"PBEWithMD5AndDES"
     *
     * @param keyt   秘钥
     * @param source ji
     * @return 解码结果
     */
    public static String decrypt(String keyt, String source) {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setPassword(keyt);
        encryptor.setAlgorithm("PBEWithMD5AndDES");
        return encryptor.decrypt(source);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy