mysql aes java解密_加密/解密的Java函數,如Mysql的AES_ENCRYPT和AES_DECRYPT
1
If you need the code to decrypt the algorithm is here JAVA
如果你需要代碼解密算法就在這里JAVA
public static String aes_decrypt(String passwordhex, String strKey) throws Exception {
try {
byte[] keyBytes = Arrays.copyOf(strKey.getBytes("ASCII"), 16);
SecretKey key = new SecretKeySpec(keyBytes, "AES");
Cipher decipher = Cipher.getInstance("AES");
decipher.init(Cipher.DECRYPT_MODE, key);
char[] cleartext = passwordhex.toCharArray();
byte[] decodeHex = Hex.decodeHex(cleartext);
byte[] ciphertextBytes = decipher.doFinal(decodeHex);
return new String(ciphertextBytes);
} catch (Exception e) {
e.getMessage();
}
return null;
}
It received a standard hex format string but variable and returns the password. Test with those in main method
它收到一個(gè)標(biāo)準(zhǔn)的十六進(jìn)制格式字符串但變量並返回密碼。用主方法測(cè)試
System.out.println(aes_encrypt("your_string_password", "your_string_key"));
System.out.println(aes_decrypt("standard_hex_format_string ", "your_string_key"));
firstable test only with encrypt, then just with decrypt. By the way you must install 'commons-codec-1.6.jar' so you can use the Hex class http://commons.apache.org/proper/commons-codec/download_codec.cgi
只有加密才能進(jìn)行第一次測(cè)試,然后只需要解密。順便說(shuō)一下,你必須安裝'commons-codec-1.6.jar',這樣你才能使用Hex類http://commons.apache.org/proper/commons-codec/download_codec.cgi
Greetings from Ecuador, Ibarra
來(lái)自厄瓜多爾的問(wèn)候,Ibarra
總結(jié)
以上是生活随笔為你收集整理的mysql aes java解密_加密/解密的Java函數,如Mysql的AES_ENCRYPT和AES_DECRYPT的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mysql查看数据倾斜_深入理解hado
- 下一篇: java求面积_Java之简单图形面积计