|
|
@ -24,23 +24,22 @@ public class KeyTest { |
|
|
|
@Test |
|
|
|
public void test3(){ |
|
|
|
// String key = "a6RlI/GctLgENUvF6DOY7w==";
|
|
|
|
String key = "g9RlI/GctLgDFJvF6DOY7w=="; |
|
|
|
String string = "sdfe@#$QW"; |
|
|
|
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); |
|
|
|
String encryptHex = aes.encryptHex(string); |
|
|
|
Console.log("{}",encryptHex); |
|
|
|
// String key = "g9RlI/GctLgDFJvF6DOY7w==";
|
|
|
|
// String string = "sdfe@#$QW";
|
|
|
|
// SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key));
|
|
|
|
// String encryptHex = aes.encryptHex(string);
|
|
|
|
// Console.log("{}",encryptHex);
|
|
|
|
} |
|
|
|
|
|
|
|
/**解密*/ |
|
|
|
@Test |
|
|
|
public void test4(){ |
|
|
|
String key = "g9RlI/GctLgDFJvF6DOY7w=="; |
|
|
|
// String key = System.getenv("CCSENS_GAME");
|
|
|
|
String encryptString = "6ba13d9930a6ad888a3704376c920a75"; |
|
|
|
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); |
|
|
|
|
|
|
|
//解密为字符串
|
|
|
|
String decryptStr = aes.decryptStr(encryptString, CharsetUtil.CHARSET_UTF_8); |
|
|
|
Console.log("{}",decryptStr); |
|
|
|
// String key = "g9RlI/GctLgDFJvF6DOY7w==";
|
|
|
|
// String encryptString = "6ba13d9930a6ad888a3704376c920a75";
|
|
|
|
// SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key));
|
|
|
|
//
|
|
|
|
// //解密为字符串
|
|
|
|
// String decryptStr = aes.decryptStr(encryptString, CharsetUtil.CHARSET_UTF_8);
|
|
|
|
// Console.log("{}",decryptStr);
|
|
|
|
} |
|
|
|
} |
|
|
|