You need to sign in to do that
Don't have an account?
Phuc 2
Create encrypt string in Aura component
Hello all,
I have an aura component where I need to encrpty a string that contains vlaues from the component. Can I do this within the component JS? Or does the data need to be sent to a controller and then pulled back again? I am encrypting a string and sending it to an external site when a user saves their record.
Thank you,
P
I have an aura component where I need to encrpty a string that contains vlaues from the component. Can I do this within the component JS? Or does the data need to be sent to a controller and then pulled back again? I am encrypting a string and sending it to an external site when a user saves their record.
Thank you,
P
https://cryptojs.gitbook.io/docs/
> encrypted:U2FsdGVkX1/JqGDagBEnmRXSuDmYb5MNL7Kuo4xT+gk= ( "Message" encoded )
> decrypted:Message (ok)
All Answers
1) Import crypto-js.min.js as a static resource
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
https://salesforce.stackexchange.com/questions/368078/encrypt-file-using-crypto-js-in-aura-component
2) No problem detected from the locker console
Ensure that your code is compatible with Lightning Locker by running the code with Locker enabled. Run the code a second time with Locker disabled to see if any errors are due to Lightning Locker restrictions.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_locker_console_evaluate.htm
https://developer.salesforce.com/docs/component-library/tools/locker-service-console
So after add the crypto-js.min.js file as a static resource.
How do I pass in the values to encrypt? CryptoJS.AES.encrypt('Name', 'address');
This can be done in the helper JS correct?
Thanks for your help.
P
https://cryptojs.gitbook.io/docs/
> encrypted:U2FsdGVkX1/JqGDagBEnmRXSuDmYb5MNL7Kuo4xT+gk= ( "Message" encoded )
> decrypted:Message (ok)