JAVA's own encryption algorithm - MD5\SHA1\BASE64

Need to import the jar package:

commons-codec.jar


    MD5

String str =  "abc" ;
DigestUtils.md5Hex(str);

   SHA1

String str =  "abc" ;
DigestUtils.shaHex(str);

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));

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325526455&siteId=291194637