import mons.codec.digest.DigestUtils;import java.util.Base64;import java.util.Scanner;/*** 加密解密** @author syl*/public class EncryptionUtils {public static void main(String[] args){String s = new Scanner(System.in).nextLine();encodeAndDecode(s);}private static void encodeAndDecode(String s) {//md5单向加密不可逆String md5 = DigestUtils.md5Hex(s);System.out.println("md5="+md5);//sha1加密不可逆String sha1 = DigestUtils.sha1Hex(s);System.out.println("sha1="+sha1);//Base64加密String encode = Base64.getEncoder().encodeToString(s.getBytes());System.out.println("base64Encode="+encode);//Base64解密byte[] decode = Base64.getDecoder().decode(encode);String decodeString = new String(decode);System.out.println("base64decode="+decodeString);}}
1500字范文,内容丰富有趣,写作好帮手!