What’s the difference between encryption and hashing?
Security is one of the core attributes of blockchain technology.
It protects information from unauthorised parties using two different security measures: encryption and hashing.
Both measures play an equally important role in blockchain security. But what do they actually mean, and what’s the difference between them?
What is encryption?
Encryption is the process of taking plain text and scrambling it into an unreadable format, or ciphertext. There are two types of encryption methods – symmetrical key encryption and public key encryption. Symmetrical key encryption is when data is both encrypted and decrypted with a single key. Think of it like a padlock, where the same key can be used to lock and unlock it.
Public key encryption, on the other hand, requires both a public key and private key, which is generated through the RSA algorithm. Public keys are used to encrypt data, but only its matching private key can decrypt it. In this kind of system, the public key is available to everyone, but only an authorised holder of the private key can access the decoded data. In other words, even if you know someone’s public key, you won’t be able to access their private key that contains decrypted information.
Public key encryption is more widely used compared to symmetrical key encryption, including in blockchain. Bitcoin uses this kind of encryption to ensure that only the rightful owner of a crypto wallet can withdraw or transfer their funds. Bitcoin’s protocol also relies on the Elliptic Curve Digital Signature Algorithm (ECDSA), which generates a new set of private keys and public keys. The public key is used with a hash function to create a user’s wallet address, whereas the private key is used to sign a digital transaction to ensure its origin is legitimate.
What is hashing?
Hashing is considered essential to blockchain management. It involves converting readable text into an unreadable text at a fixed length. So, no matter the size of the data, its unique output will always be the same length. Unlike with encryption, it is almost impossible to convert hashed data back into readable text. However, if you hash the same data again, its output will be identical. The purpose of this is to validate that the data hasn’t been altered in any way.
Typical hash functions carry out specific tasks, such as checking message integrity and authenticating information. Cryptographic hash functions add to the security features, creating an extra layer of protection that makes it more difficult for hackers to find the content of a message or any information about recipients and senders.
Cryptographic hash functions hold three main properties – they’re collision-free, hidden and puzzle friendly. No two data inputs should result in the same output hash, which itself should be difficult to decipher from its original input.
In terms of the blockchain, hashing works by processing block data through a mathematical function, which in turn creates a fixed length output. This increases security, as potential hackers won’t be able to figure out how long or short the input data is, as the output length is always the same.
What’s the difference?
One thing that encryption and hashing have in common is that they both take readable text and convert it into an unreadable format. However, the main difference between the two lies in how they function.
Encryption uses a two-way function, meaning that data can be decrypted and converted back to readable text. It can also be shared between two parties with the right decoding key. On the other hand, hashing uses a one-way function that converts data into a unique output, which cannot be reversed.
Moreover, encryption is used to protect the confidentiality of data, whereas hashing protects the integrity of the information.