java aes 偏移解密
时间: 2024-01-23 20:15:21 浏览: 141
以下是Java中使用AES解密的示例代码:
```java
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;
public class AESDecryptExample {
public static void main(String[] args) throws Exception {
String encryptedText = "2b7e151628aed2a6abf7158809cf4f3c";
String key = "0123456789abcdef";
byte[] encryptedBytes = Hex.decodeHex(encryptedText.toCharArray());
byte[] keyBytes = Hex.decodeHex(key.toCharArray());
SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
String decryptedText = new String(decryptedBytes);
System.out.println("Decrypted Text: " + decryptedText);
}
}
```
阅读全文