Exchanging Data: Compression, Encryption and Hashing

Exchanging Data: Compression, Encryption and Hashing

Compression:

  • Data compression involves encoding information using fewer bits than the original data. It can be lossless or lossy.

  • In lossless compression, the original data can be perfectly reconstructed from the compressed data. It is generally used for tasks that require exact duplicates of the original data, such as text documents, spreadsheets.

  • Lossy compression, reduces data size by eliminating non-essential information, often used to compress media like audio, video, and images where a certain loss in quality is acceptable.

  • Common compression algorithms include Huffman encoding, Run Length Encoding, and Lempel-Ziv-Welch (LZW).

Encryption:

  • Encryption is the process of converting plaintext data into secret code (ciphertext) to prevent unauthorised access.

  • Symmetric-key encryption involves the same key for encryption and decryption. Examples include the Data Encryption Standard (DES) and Advanced Encryption Standard (AES).

  • In asymmetric-key encryption, two different keys (public and private keys) are used. The public key is used to encrypt the data and the private key is used to decrypt it. It is often used in secure communication channels, digital signatures, and certificates. RSA is a typical example.

  • Hash functions are often used in combination with encryption methods to offer a further level of security.

Hashing:

  • Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string.

  • Hash functions are deterministic, which means that the same input will always result in the same hash.

  • Common applications of hashing include password storage, in databases for efficient data retrieval, and in data integrity checks.

  • Hash collisions occur when two different inputs produce the same hash output. Good hash functions hence aim to minimise these collisions.

  • Examples of popular hash function algorithms include MA5, SHA-1, and SHA-256.