zl程序教程

您现在的位置是:首页 >  其他

当前栏目

使用commons-codec包加密字符串详解编程语言

加密编程语言 使用 详解 字符串 commons codec
2023-06-13 09:20:30 时间
String str = "abc"; FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");

SHA1

String str = "abc"; 

DigestUtils.shaHex(str); 

//附.net生成SHA1的方式,生成内容跟java一致: 

String str = "abc"; 

FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");

BASE64

//加密 

String str= "abc"; // abc为要加密的字符串 

byte[] b = Base64.encodeBase64(str.getBytes(), true); 

System.out.println(new String(b)); 

//解密 

String str = "YWJj"; // YWJj为要解密的字符串 

byte[] b = Base64.decodeBase64(str.getBytes()); 

System.out.println(new String(b));

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/11036.html

cjava