I’m trying to save encrypted token in mongodb. I’m using AWS KMS to encrypt the token. Then I save it in mongo. Buw when I try to fetch it back it returns as an object with unknown characters, and not as an ArrayBuffer. So when I try to decrypt it, KMS says
‘argument must be ArrayBuffer’
The object in mongo look like this.
I tried to insert the encrypted key exactly how it return from KMS encryption.
This is the returned object from mongoDB.
My question is how to properly save/fetch the encrypted data in/from mongoDB?
Thanks for any help