MD5  {
    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 md5 (String message) {
        
try {
            MessageDigest md 
= MessageDigest.getInstance("MD5");\\想用SHA加密的话就把MD5换成SHA吧
            
return hex (md.digest(message.getBytes("CP1252")));
        } 
catch (NoSuchAlgorithmException e) {
        } 
catch (UnsupportedEncodingException e) {
        }
        
return null;
    }
    
public static void main(String[] args) {
        System.out.println (md5 (
"LiChao"));
    }

相关文章:

  • 2021-11-01
  • 2021-11-13
  • 2021-10-01
  • 2021-11-13
  • 2021-12-11
  • 2021-12-31
  • 2018-05-14
  • 2021-10-01
猜你喜欢
  • 2021-11-17
  • 2021-11-13
  • 2021-11-17
  • 2021-10-01
  • 2021-11-17
  • 2021-08-02
  • 2021-10-01
  • 2021-10-11
相关资源
相似解决方案