package com.inkasso.adapter.util;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util2 {

  public static String md5(String input) {
    byte[] code = null;
    try {
      code = MessageDigest.getInstance("md5").digest(input.getBytes());
    } catch (NoSuchAlgorithmException e) {
      code = input.getBytes();
    }
    BigInteger bi = new BigInteger(code);
    return bi.abs().toString(32).toUpperCase();
  }

  public static String generatePasswordMD5(String input, String salt) {
    if (StringUtils.isEmpty(salt)) {
      salt = "";
    }
    return md5(salt + md5(input));
  }

  public static void main(String[] args) {
    System.out.println(md5("111111"));
  }

}
