解密方法从 java 到 php
Decrypt method from java to php
我在 java 中有这个方法,我想在 php 中重写它。
public static final byte[] keyValue = new byte[] { 'T', 'h', 'e', 'B', 'e',
's', 't', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y' };
public final static String ALGO = "AES";
public static String Dcrypt(String encryptedData) {
Key key = new SecretKeySpec(keyValue, ALGO);
// Key key = generateKey();
try {
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = Base64.decodeBase64(encryptedData);
byte[] decValue = c.doFinal(decordedValue);
decryptedValue = new String(decValue);
} catch (Exception e) {
}
return decryptedValue;
}
我应该在 php 中使用什么方法来实现。
一些来源:
解密密码为:password
我最终使用了来自 http://aesencryption.net/
的代码
更改输入键和块大小以满足您的需要。
我在 java 中有这个方法,我想在 php 中重写它。
public static final byte[] keyValue = new byte[] { 'T', 'h', 'e', 'B', 'e',
's', 't', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y' };
public final static String ALGO = "AES";
public static String Dcrypt(String encryptedData) {
Key key = new SecretKeySpec(keyValue, ALGO);
// Key key = generateKey();
try {
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = Base64.decodeBase64(encryptedData);
byte[] decValue = c.doFinal(decordedValue);
decryptedValue = new String(decValue);
} catch (Exception e) {
}
return decryptedValue;
}
我应该在 php 中使用什么方法来实现。
一些来源:
解密密码为:password
我最终使用了来自 http://aesencryption.net/
的代码更改输入键和块大小以满足您的需要。