I've 16 bytes data I'm storing in Uint8Array. I need to store this data in the browser and must get it in some other class.
so my code looks like this:
const ivBytes = window.crypto.getRandomValues(new Uint8Array(16));
localStorage.setItem("iv",JSON.stringify(ivBytes))
console.log("content of ivBytes:" + ivBytes)
and in other class I try to get data like this but it doesnt work
let array = JSON.parse(localStorage.getItem("iv"))
console.log("the iv value we get is: " + ivBytes)
but when I try to get the content of array, it doesnt give me exactly the content of the ivBytes. the output is as follows:
How can I store Uint8array in browser and get it the same way in other class using localStorage? thanks in advance.