1.3 Compression, Encryption, Hashing

Cards (20)

  • 2 different methods of compression:
    • Lossy
    • Lossless
  • Purpose of compression:
    • Reduce size of files
    • Reduce download times
    • Reduce storage requirements
    • Make best use of bandwith
  • Lossy compression:
    • Some data is permanently removed
    • Reduces quality - significantly reduces file size
    • Suitable for images, audio and video
    • Not able to recreate original file
    • Compression ratio may be adjusted depending on bandwith
  • Lossless compression:
    • None of the original data is lost - rewrites original data in more efficient format
    • The original file can be recreated when uncompressed
    • Suitable for executable files and documents
  • The 2 different methods of lossless compression:
    • Dictionary coding
    • Run length encoding
    • Dictionary encoding is ideal for compression of text-based documents
    • Run-length encoding is more suited to the compression of images
  • Dictionary coding:
    • Works by building an index that we visualize as a table
    • Every item of entry is encoded and is indexed
    • The compressed file consists of: The dictionary index, and the sequence of occurrences
  • In run-length encoding:
    • The information is stored in what we call frequency/data pairs
    • See the example attached
  • Encryption:
    • The process of encoding/scrambling a message
    • So it can be read only be the sender and the intended recipient
  • Symmetric encryption:
    • Where a single key is used to both encrypt and decrypt a message
    • Both parties need to know the key.
  • Disadvantages of symmetric encryption:
    • Interception of the key
    • Duplication of the key production process to acquire a copy of the key
  • Asymmetric encryption:
    • Where 2 different keys are used - Public and Private key
    • Public key is used to encrypt the message
    • The other key is used to decrypt the message
  • Asymmetric encryption:
    • Encryption with Public Key: User A uses User B's public key to encrypt the message
    • Decryption with Private Key: User B uses their private key to decrypt the message
    • Authentication with Private Key: User A signs the message with their private key
    • Verification with Public Key: User B verifies the signature using User A's public key
  • Hashing is different from encryption:
    • As it a one-way process
    • You cannot get back to the original value even from the hashing algorithm
  • Hashing:
    • Prevents information like passwords from being read by hacker
    • one-way transformation of data
    • The details are stored by using an hashing function
    • If the hacker gains access to the file contain the passwords - they will only be able to read the hashing values
  • On average hashing:
    • Provides a constant O(1) time complexity
  • Advantages of asymmetric encryption:
    • No one else will be able to read the message
    • The message is authentic
    • Can be sure the message hasn't been modified
  • Characteristics of a good hashing algorithm:
    • Low chance of collision to reduce risk of different files being marked as the same
    • Quick to calculate
    • Provide a smaller output then input so quicker to compare hashes than original data
  • Symmetric Encryption
    • both the sender and the receiver share the same private key which they distribute to eachother in a key exchange
    • key is used for both encrypting and decrypting data
    • private key is kept secret. if key is intercepted during key exchange, then any communications sent can be decrypted
  • Asymmetric Encryption
    • 2 keys used: one public and one private
    • public key can be published anywhere, private kye must be kept secret. together known as a key pair and mathematically related
    • single key cant be used, messages encrypted with recipient's public key can only be decrypted with recipient's private key
    • if someone wants to send a message, they must find your public key and then message is encrypted with your public key