我正在使用Apache骆驼CryptoDataFormat加密正文,为此我有自己的加密密钥,它是一个字符串,并使用“ AES / CBC / PKCS5Padding”算法。我的加密不正确,也没有正确解密。
我的代码如下:
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-crypto</artifactId>
<version>2.23.1</version>
</dependency>
camel route:
@Override
public void configure() throws Exception {
SecretKeySpec keySpec = new SecretKeySpec(Base64.getDecoder().decode("ABCKEY123"), "AES");
CryptoDataFormat cryptoFormat = new CryptoDataFormat("AES/CBC/PKCS5Padding", keySpec);
from("{{direct:ABC}}")
.process(someprocessor)
.marshal(xmlDataFormat)
.log("MARSHALLED message: ${body}")
.marshal(cryptoFormat)
.log("Encrypted data: ${body}")
.unmarshal(cryptoFormat)
.log("Decrypted data: ${body}").end();