| | |
| | | package com.zy.asrs.wms.utils; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.MessageDigest; |
| | | |
| | | public class EncryptUtils { |
| | | |
| | | public static String md5(String plainString) { |
| | | String cipherString = null; |
| | | try { |
| | | // 获取实例 |
| | | MessageDigest messageDigest = MessageDigest.getInstance("MD5"); |
| | | // 计算摘要 |
| | | byte[] cipherBytes = messageDigest.digest(plainString.getBytes(StandardCharsets.UTF_8)); |
| | | // 输出为16进制字符串 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (byte b : cipherBytes) { |
| | | sb.append(String.format("%02x", b)); |
| | | } |
| | | cipherString = sb.toString(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return cipherString; |
| | | } |
| | | |
| | | } |
| | | package com.zy.asrs.wms.utils;
|
| | |
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.security.MessageDigest;
|
| | |
|
| | | public class EncryptUtils {
|
| | |
|
| | | public static String md5(String plainString) {
|
| | | String cipherString = null;
|
| | | try {
|
| | | // 获取实例
|
| | | MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
| | | // 计算摘要
|
| | | byte[] cipherBytes = messageDigest.digest(plainString.getBytes(StandardCharsets.UTF_8));
|
| | | // 输出为16进制字符串
|
| | | StringBuilder sb = new StringBuilder();
|
| | | for (byte b : cipherBytes) {
|
| | | sb.append(String.format("%02x", b));
|
| | | }
|
| | | cipherString = sb.toString();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return cipherString;
|
| | | }
|
| | |
|
| | | }
|