Ver código fonte

添加密钥转换hash方法

gao.qiang 1 ano atrás
pai
commit
92bb83693c

+ 14 - 5
base-common/src/main/java/com/ozs/common/utils/stateSecrets/SM4Utils.java

@@ -138,29 +138,38 @@ public class SM4Utils
 		}
 	}
 
+
+	public  static  void hash(){
+		//授权类型+环境变量+客户端编号
+		String  key="1+1+1005";
+		System.out.println(key.hashCode());
+	}
+
 	public static void main(String[] args) throws IOException
 	{
-		String plainText = "abcd";
+//		hash();
+		
+		String plainText = "4370780c9a8c43e5";
 
 		SM4Utils sm4 = new SM4Utils();
 		sm4.hexString = false;
 
 		System.out.println("ECBģʽ");
-		String cipherText = sm4.encryptData_ECB(plainText,"4370780c9a8c43e5");
+		String cipherText = sm4.encryptData_ECB(plainText,"58792429c08c43e9");
 		System.out.println("加密后: " + cipherText);
 		System.out.println("");
 
-		plainText = sm4.decryptData_ECB(cipherText,"4370780c9a8c43e5");
+		plainText = sm4.decryptData_ECB(cipherText,"58792429c08c43e9");
 		System.out.println("解密后: " + plainText);
 		System.out.println("");
 
 		System.out.println("大");
 		sm4.iv = "UISwD9fW6cFh9SNS";
-		cipherText = sm4.encryptData_CBC(plainText,"4370780c9a8c43e5");
+		cipherText = sm4.encryptData_CBC(plainText,"58792429c08c43e9");
 		System.out.println("加密后: " + cipherText);
 		System.out.println("");
 
-		plainText = sm4.decryptData_CBC(cipherText,"4370780c9a8c43e5");
+		plainText = sm4.decryptData_CBC(cipherText,"58792429c08c43e9");
 		System.out.println("解密后: " + plainText);
 	}