Closed Anderson-Juhasc closed 5 months ago
Well, I'm not sure if it's a right way but worked, I tried this code to encode and decode the private key saved in local storage:
Encode:
const myUint8Array = new Uint8Array([10, 20, 30]); const encodedString = btoa(String.fromCharCode.apply(null, myUint8Array)); localStorage.setItem('myDataKey', encodedString);
Decode:
const encodedString = localStorage.getItem('myDataKey'); const decodedString = atob(encodedString); const uint8Array = Uint8Array.from(decodedString.split('').map(c => c.charCodeAt(0)));
Recent nostr-tools versions are return private keys in Uint8Array:
I had to add the script webextension-polyfill to run, but now I have this problem when I try to save private key in Uint8Array format:
Uncaught (in promise) Error: Cannot serialize value to JSON at browser-polyfill.js:772:26
@fiatjaf how did you solve this?
Thanks.