中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

使用Jasypt來加密解密的Java示例代碼

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
加密:
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
 
/**
 *把密文放到配置文件中的時候要注意:
 * ENC(密文)
 */
public class ConfigEncryptUtils {
    public static void main(String[] args){
        //加密工具
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        //加密配置
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        config.setAlgorithm("PBEWithMD5AndDES");
        //自己在用的時候更改此密碼
        config.setPassword("fdfd");
        //應用配置
        encryptor.setConfig(config);
        String plaintext="root";
        //加密
        String ciphertext=encryptor.encrypt(plaintext);
        System.out.println(plaintext + " : " + ciphertext);
    }
}

解密:
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
 
/**
 *把密文放到配置文件中的時候要注意:
 * ENC(密文)
 */
public class ConfigEncryptUtils {
    public static void main(String[] args){
        //加密工具
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        //加密配置
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        config.setAlgorithm("PBEWithMD5AndDES");
        //自己在用的時候更改此密碼
        config.setPassword("fdfd");
        //應用配置
        encryptor.setConfig(config);
        String ciphertext="azL9Cyp9H62r3eUgZ+TESw==";
        //解密
        String plaintext=encryptor.decrypt(ciphertext);
        System.out.println(ciphertext + " : " + plaintext);
    }
}
Jasypt是一個Java開源庫,可以使開發(fā)者不需太多操作就可以給Java項目添加基本加密功能,而且不需要知道加密原理。
1.該開源項目可用于加密任務與應用程序,例如加密密碼、敏感信息和數據通信
2.還包括高安全性、基于標準的加密技術、可同時單向和雙向加密的加密密碼、文本、數字和二進制文件。
3.Jasypt還符合RSA標準的基于密碼的加密,并提供了無配置加密工具以及新的、高可配置標準的加密工具。
4.加密屬性文件(encryptable properties files)、Spring work集成、加密Hibernate數據源配置、新的命令行工具、URL加密的Apache wicket集成以及升級文檔。
5.Jasypt也可以與Acegi Security整合也即Spring Security。Jasypt亦擁有加密應用配置的集成功能,而且提供一個開放的API從而任何一個Java Cryptography Extension都可以使用Jasypt。

標簽: 安全 開發(fā)者 通信

版權申明:本站文章部分自網絡,如有侵權,請聯系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯系。

上一篇:asp.net獲取訪客真實IP地址的函數

下一篇:C#通過Socket在網絡間發(fā)送和接收圖片的演示代碼