首页 > 编程知识 正文

jasypt加解密命令,jasypt 解密

时间:2023-05-05 04:53:49 阅读:274216 作者:907

加密后密码:例如ENC(yyrqk9reuY5kScmS3D9mWQ==) jasypt: encryptor: password: 加盐

加密:

java -cp C:UsersAdministrator.m2repositoryorgjasyptjasypt1.9.2jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="原密码" password=盐 algorithm=PBEWithMD5AndDES

java -cp C:UsersAdministrator.m2repositoryorgjasyptjasypt1.9.3jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="原密码" password=盐 algorithm=PBEWITHHMACSHA512ANDAES_256 ivGeneratorClassName=org.jasypt.iv.RandomIvGenerator

解密:
java -cp C:UsersAdministrator.m2repositoryorgjasyptjasypt1.9.2jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI input="加密后的密码" password=盐 algorithm=PBEWithMD5AndDES

java -cp C:UsersAdministrator.m2repositoryorgjasyptjasypt1.9.3jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI input="加密后的密码" password=盐 algorithm=PBEWITHHMACSHA512ANDAES_256 ivGeneratorClassName=org.jasypt.iv.RandomIvGenerator

 

input:是数据库的明文密码

password:是机密的盐

algorithm:是加密的方式(默认)

 

Maven依赖
<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>1.16</version> </dependency>

3 调用JAVA API 生成密文

public static void main(String[] args) { BasicTextEncryptor textEncryptor = new BasicTextEncryptor(); //加密所需的salt(盐) textEncryptor.setPassword("G0CvDz7oJn6"); //要加密的数据(数据库的用户名或密码) String username = textEncryptor.encrypt("root"); String password = textEncryptor.encrypt("root123"); System.out.println("username:"+username); System.out.println("password:"+password);}

4. jasypt-1.9.3.jar 加密一直报错Operation not possible (Bad input or parameters)

改两个参数就解决了 algorithm=PBEWITHHMACSHA512ANDAES_256 ivGeneratorClassName=org.jasypt.iv.RandomIvGenerator

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。