Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

php - I want to encrypt blob using SHA in javascript

I want to encrypt blog using SHA in javascript so that I can send the encrypted blob chunk to server and where I can decrypt it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is not possible.

SHA is a cryptographic hash function, not an encryption function - the result is not reversible. See Fundamental difference between Hashing and Encryption algorithms for an in-depth explanation.

Now, to really encrypt data in JavaScript (say with AES), there are several options. Since it is hard to get cryptography and key exchange correct, using a hand-rolled encryption scheme may be no better than plain-text. As such, normally one would just use HTTPS to ensure the entire channel is securely1 encrypted.


1 HTTPS itself is "secure" with the correct negotiation options and patches.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...