zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    装饰器
    目录和文件操作
    网络通信过程
    epoll并发
    laravel(包含lumen)框架中的跨域函数实例
    windows使用nginx
    nginx反向代理配置 其实很简单
    前端html页面使用marked点亮你的代码
    PHPWAMP开启SSL,PHPWAMP配置ssl证书
    php接收并存储base64位字符串图片
  • 原文地址:https://www.cnblogs.com/dw3306/p/9342275.html
Copyright © 2011-2022 走看看