简体   繁体   中英

How to encrypt some string in JavaScript which is not going to visible on client side?

I have one AWS KEY in my angular js file to upload file to AWS s3 but somehow someone will saw my AWS Key and secret key and it was hacked. so now i want to do some encryption for that string so it is not visible on client side on source file or anywhere else.

Thanks in advance.

i've tried atob() and btoa() but still i dont want to store my original kwy in any variable.

You can't. Giving client-side code access to your AWS key would require you to make that key available to client-side code, and hence to anyone reading your code. There is no way to distinguish between the two cases.

If you need to allow client-side code to upload files to S3, use presigned URLs to authorize specific uploads . Under no circumstances should you ever give clients access to your AWS key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM