Wha开发者_开发技巧t is the difference between encryption and a digest?
Encryption takes a plain text and converts it to an encrypted text using a key and an encryption algorithm. The resulting encrypted text can later be decrypted (by using the same key and algorithm).
A digest takes a plain text and generates a hashcode which can be used to verify if the plain text is unmodified but cannot be used to decrypt the original text from the hash value.
Encryption conceals the contents of the plaintext, while a digest is a special kind of hash that acts as a sort of fingerprint for the data. If the message digest is encrypted with a private key, this can be used as a digital signature to ensure that it came from a particular source.
Encryption is the transformation of plaintext into ciphertext using a cryptographic function. A one-way cryptographic function such as a cryptographic hash function is irreversible. A two-way cryptographic function such as a symmetric or asymmetric key based function is reversible.
A message digest uses encryption to verify that the contents of a message aren’t modified in transit between the sender and receiver of the message. A message digest is a fixed-length string that is generated by applying a cryptographic hash function to the contents of an entire message. It is computed by the sender and attached to the message. When the receiver receives the message, the receiver can re-compute the message digest and compare it to the original message digest in the message. If the two strings are equal, the receiver can be sure that the message wasn’t altered in transit.
A message digest is also called a hash or fingerprint.
精彩评论