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"));
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2021-11-17
  • 2021-12-20
  • 2022-12-23
  • 2021-10-20
  • 2021-07-16
相关资源
相似解决方案