diff --git a/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java b/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java index 7ef363e..a459df9 100644 --- a/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java +++ b/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java @@ -5,39 +5,50 @@ import java.security.NoSuchAlgorithmException; /** * SHA加密解密工具 + * * @author tajochen */ public class EncryptDecryptUtil { + public static void main(String[] args) { + String password = "zzpassword"; + String salt = "2b1d8a197c24eb36"; + String encrypt = encry256(password + salt); + System.out.println("encrypt = " + encrypt); + } + /** * SHA-256加密 + * * @param strText * @return */ - public static String encry256(final String strText){ - return encrySha(strText,"SHA-256"); + public static String encry256(final String strText) { + return encrySha(strText, "SHA-256"); } /** * SHA-512加密 + * * @param strText * @return */ - public static String encry512(final String strText){ - return encrySha(strText,"SHA-512"); + public static String encry512(final String strText) { + return encrySha(strText, "SHA-512"); } /** * 基础SHA加密 + * * @param strText * @param strType * @return */ - private static String encrySha(final String strText, final String strType){ + private static String encrySha(final String strText, final String strType) { // 返回值 - String strResult=null; + String strResult = null; // 是否是有效的字符串 - if (strText != null && strText.length()>0){ + if (strText != null && strText.length() > 0) { // 加密开始,创建加密对象,并传入加密类型 try { MessageDigest messageDigest = MessageDigest.getInstance(strType); @@ -55,12 +66,11 @@ public class EncryptDecryptUtil { } // 得到返回的结果 strResult = strHexString.toString(); - } - catch (NoSuchAlgorithmException e) { + } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } - return strResult; + return strResult; } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 987b328..d82686e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.port = 6801 +server.port = 6101 ## 数据源配置 spring.datasource.url = jdbc:postgresql://118.24.27.47:5432/fire_point