Search code examples
aws-sdkamazon-kmsaws-sdk-java

AWS(AwsCrypto) encryption result vary every time


The returned string vary every when I execute below code. Is there something I can config so that return fixed result?

final AwsCrypto crypto = new AwsCrypto();
new String(Base64.getEncoder().encode(crypto.encryptData(masterKeyProvider, EXAMPLE_DATA).getResult()))

Solution

  • In the SDK, AWS have add some signature which is random and can not be removed, so the encrypted string is not constant. https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/algorithms-reference.html