Issue
In Angular, How to encrypt a value and store it in Local Storage and then Retrieve and Decrypt it.
Example
a: Number = 5;
b: Number = 6;
c: Number;
c= a+b;
localStorage.setItem('result', (this.c)); // I wan to encrypt and store it in local storge here
localStorage.getItem('result'); // I want to decrypt and get the value
Which is the best way and how?
Solution
There are several ways do this but to decide which is best way to do? You need decide that what are trying to achieve with this encryption/decryption? Ideally, you can't secure local storage and it is not recommended to store any sensitive data in local storage. Couple of options to use store encrypted data in locals storage/
- secure-web-storage
- secure-ls
- localstorage-slim (tutorial)
- BASE64 Encoding/Decoding. Encoding/Decoding means transforming data from one form to another for transmission or storage purposes. Transformed data can easily be reversed by anybody. This is not a encryption and can't secure data.
other similar libraries
Answered By - nayakam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.