MD5加密

import android.annotation.SuppressLint;
import java.security.MessageDigest;

public class MD5 {
    
    @SuppressLint("DefaultLocale") 
    public static String hex(byte[] array) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; ++i) {
            sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100)
                    .toUpperCase().substring(1, 3));
        }
        return sb.toString();
    }

    public static String encrypt(String message) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            return hex(md.digest(message.getBytes("ISO8859-1")));
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(encrypt("Hello world"));
    }
MD5

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-11-03
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案