Closed shemeshg closed 2 years ago
You should be encrypting with a pair.
var data = 'some data to encrypt'
var pair = await SEA.pair();
var enc = await SEA.encrypt(data, pair);
Then, you may decrypt with the same pair.
var dec = await SEA.decrypt(data, pair);
console.log(dec) // 'some data to encrypt'
Hi
Thanks for the response, With pair produces the same undesired result (of stripped Quotation Marks)
data is: "some data to encrypt"
decrypted is: some data to encrypt
for
const data = JSON.stringify('some data to encrypt')
const pair = await SEA.pair();
const enc = await SEA.encrypt(data, pair as IGunCryptoKeyPair);
const dec = await SEA.decrypt(enc, pair as IGunCryptoKeyPair);
console.log(`data is: ${data}`)
console.log(`decrypted is: ${dec}`)
The data string looses it's Quotation Marks
If you'll try to JSON.parse(dec) it will fail. while JSON.parse(data) will succeed
What I don't understand is why you're trying to JSON.stringify()
what is already a string?
Ok, just tried with
const data = {test:'some data to encrypt'}
and it worked fine.
Did not know, the SEA.encrypt accept Object and does the Stringify for me already I thought that encrypt might reject non String object as parameter.
Thanks
running this
results this
However Expected/correct result is this