Test Text: username
Encryption Result:
uname1 = b'\x01\x02\x02\x00x]n\xe8\xe6\xae\xae\xdf\xb7F\x87^!\xc1l8\x0eC\xb0\xcc\xf5\x00\xe7%j\xa2S\xc7\x84\xb4\xf2\xea]\x01K\xf9\xf9\xe7c\xa7\xc8A\xec\xf3\xd1\x9f\xd9\x9f\x86\xb7\x00\x00\x00f0d\x06\t*\x86H\x86\xf7\r\x01\x07\x06\xa0W0U\x02\x01\x000P\x06\t*\x86H\x86\xf7\r\x01\x07\x010\x1e\x06\t`\x86H\x01e\x03\x04\x01.0\x11\x04\x0c;\xaa\xe9\x03\x84\x00Z\x96"\t/\x18\x02\x01\x10\x80#\xdd\xf1C\xafy\x1e\xf07Z\x0fI_\ncr\x80\xdc\xf5>o\xb9`\x1a\xf8\x0c\xec\x0f\xc3\xd1\x8f\xdd\xe6~\xca\x16'
Supposedly the following is also the result of username being encrypted by KMS and I have to decrypt it:
uname2 = "AQICAHiRhVOkDetQTv51rimwyQpfSKJYi6zefQF+Wz32zFAYKwEyMctEfb/Oos0Mq48uPt2AAAAAZjBkBgkqhkiG9w0BBwagVzBVAgEAMFAGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM7vxxEHGmH5vHJX1zAgEQgCM2Uee6e6zM0mQgli9kXQVJ3pNid+waG6nrDnB9P3VjVquaCA=="
Decrypting uname1 works just fine but uname2 does not work and results in the following error:botocore.errorfactory.InvalidCiphertextException: An error occurred (InvalidCiphertextException) when calling the Decrypt operation:
Documentation I was following: https://docs.aws.amazon.com/kms/latest/developerguide/programming-encryption.html
I am trying to decryptuname2
, uname1
was just a local test I did.
Is this a character encoding issue? Why do the strings look so different?
You simply need to decode the uname2 string, as it is Base64 encoded after being encrypted. You will then be able to decipher it.