Encryption in Laravel and Decryption in javascript? #52547
Replies: 3 comments 3 replies
-
What you need that for? SSL is doing the encryption between server and end user... |
Beta Was this translation helpful? Give feedback.
-
An example for hashing: example js:
equivalent in php: \hash_hmac('sha256', 'your string', $secret); I guess there should be something similar also for encryption/decryption. |
Beta Was this translation helpful? Give feedback.
-
There isn't a method in the framework itself, however it can definitely be done, with one huge condition: you need to be happy for the decryption key to be sent to the browser and it's safe for the user to obtain it. You cannot decrypt (or encrypt) in the browser without the user having access to the key. Although using public/private keys would help in some ways. If that's acceptable, pick your encryption type (symmetric or asymmetric), and algorithm, find a way to perform that in both JS and PHP (i.e. find a package), and then write the code. Don't use Laravel's encryption tools, and definitely don't use Laravel's encryption keys. Generate custom keys specifically for this - unique per user. All of that said, if you're not familiar with cryptography, you need to be really careful with this stuff - it's very easy to leave massive holes and vulnerabilities. Find someone with experience who can review your work and help you ensure you have a secure implementation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Are there any ways to use
encryption
in Laravel and we candecrypt
in javascript?Can we use some package like: Crypto, CryptoJs...
Beta Was this translation helpful? Give feedback.
All reactions