Compression, Encryption and Hashing

Compression, Encryption and Hashing

Compression:

  • Data compression is a procedure of reducing the size of a file or data set. It saves storage space and speeds up data transfer over network connections.
  • There are two types of data compression: Lossless and Lossy.
    • Lossless compression ensures that original data can be perfectly recreated from the compressed data. Example formats include .zip and .gif.
    • Lossy compression discards some of the data to cut down the size, which can result in some loss of the data fidelity. Example formats include .jpg and .mp3.
  • For exchanging data, it is essential to choose the appropriate compression type depending on the requirement of data accuracy and size limitations.

Encryption:

  • It is the process of converting plain text data into a format that can’t be read without a decryption key. It prevents unauthorised access to the data.
  • Two types of encryption methods are Symmetric and Asymmetric.
    • Symmetrical encryption uses a single key, both for encryption and decryption. The issue is how to share the encryption-key securely.
    • Asymmetrical encryption uses two different keys (Public and Private). The public key is used for encryption and the private key for decryption. This resolves the key exchange problem of symmetric encryption.

Hashing:

  • Hashing converts data of any size to a fixed size. It is mainly used for data validation.
  • Data input into a hash function generates an unique hash code. If even a single bit changes in the input, hash code will be different. Hence, it is used to identify tampering or corruption of data.
  • One-way hashing means the original data cannot be retrieved from the hash code. This is used in password storage where the original password is not stored, only the hash code is saved. If this hash matches with the hash of the input password, access is granted.
  • Collision occurs when two different inputs generate the same hash. Good hash functions make this highly unlikely.