• Md5加密工具类


    Md5加密工具类:

     1 package com.microClass.util;
     2 
     3 /**
     4  * Created by asus on 2017/4/26.
     5  */
     6 import java.io.UnsupportedEncodingException;
     7 import java.security.MessageDigest;
     8 import java.security.NoSuchAlgorithmException;
     9 
    10 import org.apache.commons.codec.binary.Hex;
    11 
    12 public class MD5Util{
    13 
    14     public static String encode(String origin, String charsetname){
    15         String resultString = null;
    16         resultString = new String(origin);
    17         MessageDigest md;
    18         try{
    19             md = MessageDigest.getInstance("MD5");
    20         }catch(NoSuchAlgorithmException e){
    21             throw new RuntimeException(e);
    22         }
    23         if(charsetname == null || "".equals(charsetname)){
    24             resultString = Hex.encodeHexString(md.digest(resultString.getBytes()));
    25         }else{
    26             try{
    27                 resultString = Hex.encodeHexString(md.digest(resultString.getBytes(charsetname)));
    28             }catch(UnsupportedEncodingException e){
    29                 throw new RuntimeException(e);
    30             }
    31         }
    32         return resultString;
    33     }
    34 
    35     public static String encode(String origi){
    36        // String st=origi+"45678";
    37         return encode(origi,"utf-8");
    38     }
    39     public static String encodeStrong(String origi){
    40         if (origi!=null){
    41             int length = origi.length();
    42             String str=origi+String.valueOf(length)+origi;
    43             //123456 6 123456
    44             return encode(str,"utf-8");
    45         }
    46         return encode("12345678","utf-8");
    47     }
    48     public static void main(String[] args) {
    49         System.out.println("md5="+MD5Util.encode("5"));
    50     }
    51 }

    MD5 升级优化 加盐(Java)

    https://blog.csdn.net/dingsai88/article/details/51637977

  • 相关阅读:
    php-有时候你会疑惑的小问题
    phpDocumentor生成文档
    mongodb重命名集合、数据库
    资料网站
    Service(服务)
    Component(组件)
    Module(模块)
    你不屑于大器晚成,就只能平庸一生
    是狼就磨好牙,是羊就练好腿!
    将Excel数据导入数据库
  • 原文地址:https://www.cnblogs.com/dw3306/p/9342275.html
Copyright © 2020-2023  润新知