We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I used crypto-js to encode & decode my data before saving via persistenAtom
crypto-js
persistenAtom
import { persistentAtom } from "@nanostores/persistent"; import CryptoJS from 'crypto-js' const ENCRYPTION_KEY = 'my-secret-key' const encrypt = (data: any):string => CryptoJS.AES.encrypt(JSON.stringify(data), ENCRYPTION_KEY).toString() const decrypt = (encryptedData:string):any => { const bytes = CryptoJS.AES.decrypt(encryptedData, ENCRYPTION_KEY) return JSON.parse(bytes.toString(CryptoJS.enc.Utf8)) } export const counterP = persistentAtom<number>("counter", 0, { encode: encrypt, decode: decrypt, }); export const add = action(counterP, "add", (store) => { counterP.set(counterP.get() + 1); });
Whenever i load the stored data using counterP.get() it shows me the encrypted data (not the actual data after decoding it as it was supposed to)
counterP.get()
decode the data stored in localStorage before loading it into the Atom Store
decode
Would love if that custom storage issue gets resolved as described here #30
The text was updated successfully, but these errors were encountered:
Could you show an idea in PR (you can make a draft PR without tests)?
Sorry, something went wrong.
No branches or pull requests
I used
crypto-js
to encode & decode my data before saving viapersistenAtom
Code
Issue
Whenever i load the stored data using
counterP.get()
it shows me the encrypted data (not the actual data after decoding it as it was supposed to)Resolve
decode
the data stored in localStorage before loading it into the Atom StoreWould love if that custom storage issue gets resolved as described here #30
The text was updated successfully, but these errors were encountered: