Security Intro


  1. Difference between Hash and Cipher
  2. Difference between Hash and Encryption

Difference between hash, cipher and encrpyption

A hash is used to take a message of any length and produces a fixed-sized output length using a hash function. For example the SHA256 hash function produces a 256-bit hash value regardless of the input message length. Given a hash value it is not possible in general to determine the original message because many different messages could generate the same hash value. A hash function destroys information in the general case.

A cipher, on the other hand, takes a message of any length and produces an output of equal or greater length. It does not destroy information. A cipher output (called a ciphertext) can be decoded to produce the original message.

Encryption is the process of encoding simple text and other information that can be accessed by the sole authorized entity if it has a decryption key

Hashing is used to validate the integrity of the content by detecting all modifications and thereafter changes to a hash output. Encryption encodes data for the primary purpose of maintaining data confidentiality and security. It requires a private key to reversible function encrypted text to plain text.

In short, encryption is a two-way function that includes encryption and decryption whilst hashing/ciphers are a one-way function that changes a plain text to a unique digest that is irreversible.