zoukankan      html  css  js  c++  java
  • MD5 Util

    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    
    import org.apache.http.impl.auth.UnsupportedDigestAlgorithmException;
    
    import android.util.Log;
    
    
    public final class MD5 {
        private static final String LOG_TAG = "MD5";
        private static final String ALGORITHM = "MD5";
    
        private static char sHexDigits[] = {
            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
    };
        private static MessageDigest sDigest;
    
        static {
            try {
                sDigest = MessageDigest.getInstance(ALGORITHM);
            } catch (NoSuchAlgorithmException e) {
               // Log.e(LOG_TAG, "Get MD5 Digest failed.");
                throw new UnsupportedDigestAlgorithmException(ALGORITHM, e);
            }
        }
    
        private MD5() {
        }
    
        
        final public static String encode(String source) {
            byte[] btyes = source.getBytes();
            byte[] encodedBytes = sDigest.digest(btyes);
    
            return Utility.hexString(encodedBytes);
        }
    
    
        public static void main(String[] args) {
    
            System.out.println(MD5.encode("Today i'm not busy!"));
        }
    }
    //关于
    MessageDigest 类为应用程序提供信息摘要算法的功能,如 MD5 或 SHA 算法。信息摘要是安全的单向哈希函数,它接收任意大小的数据,并输出固定长度的哈希值。

     //个人举得这篇博文还是不错的   http://blog.sina.com.cn/s/blog_4f36423201000c1e.html

    
    
  • 相关阅读:
    leetcode
    vue初尝试--组件
    vue初尝试--项目结构
    vue初尝试--新建项目
    SQL取xml中节点值
    UI设计
    Asp.NET中Gridview CSS---Office2003风格
    Jquery+JSON+WebService使用总结
    ASP.NET 如何固定表格表头(fixed header)
    项目总结
  • 原文地址:https://www.cnblogs.com/mauiie/p/3664136.html
Copyright © 2011-2022 走看看