Encryption and hashing are two terms widely used in cryptography. In this article, we will understand the difference between encryption and hashing.
1. Encryption
Encryption is the process of converting an ordinary readable message (called plaintext) into a spam or unreadable message (called ciphertext). The ciphertext obtained from encryption can be easily converted to plaintext using the encryption key. Some examples of encryption algorithms are RSA, AES, and Blowfish.
2. Hash
Hashing is the process of converting information into a key using a hash function. The original information cannot be retrieved from the hash key in any way. Typically, hash keys are stored in a database and compared to check if the original information matches. They are commonly used to store login passwords. Some examples of hashing algorithms are MD5, SHA256. Difference between hashing and encryption:
Base | NoSQL | NewSQL |
---|---|---|
definition | It is the process of converting information into shorter fixed values called keys used to represent the original information | It's the process of securely encoding data so that only authorized users who know the key or passphrase can retrieve the original data for others, it's just rubbish |
Purpose | The purpose of a hash is to index and retrieve items from a database. This process is very fast. | The purpose of encryption is to transform data to keep it private from others |
reverse process | The hash code or key cannot be reversed to the original information in any way. It can only be mapped and check the hash code, if the hash code is the same, the information is the same, otherwise not. Original information could not be retrieved. | The original information can be easily retrieved if we know the encryption key and algorithm used for encryption. |
Safety | It is more secure than encryption. | It is less secure than hashing |
file creation | Normally it tries to generate a new key for each piece of information passed to the hash function, but in rare cases it may generate the same key which is commonly called a collision. | It will always generate a new key for each message. |
example | MD5, SHA256 | RSA, AES, and Blowfish |
message | length Hash information usually has a small fixed length. It doesn't grow with message length. | Encrypted messages are not of fixed length. It grows with the length of the message. |