Compression, Encryption, and Hashing

Cards (9)

  • Compression:
    • Reduce file size
    • Reduce download time
    • Reduce storage requirements
    • Makes best use of bandwidth
    Two methods: Lossy and Lossless
    The human eye cannot tell when an image has lost a little bit of detail so lossy is fine
    Lossless is good for images with large areas of the same colour such as cartoons but not suited for full-colour photography
  • Lossy - best for images, audio, video
    Lossless - best for executables and text documents
  • Two types of lossless compression:
    • Dictionary coding (text)
    • Run-length encoding (images)
  • Dictionary coding builds an index we can visualise as a table.
    Each data item in the file is recorded in the table along with a unique code
    There is then a sequence of occurrences which tells you in what order items appear
  • Run-length encoding that is useful on images with a lot of the same colour in a row
    We store these as sequences instead of storing each individual binary code for each pixel
    So instead of storing 000000010000
    (0 = white, 1 = black)
    we can store 7W 1B 4W
  • Two types of encryption:
    • Symmetric encryption
    • Asymmetric encryption
  • In symmetric encryption, a single key is used to encrypt and decrypt a message.
    This means both parties need to know the key and keep it secret
    An alternate can be generated when a new message is sent
    This is vulnerable to:
    • Interception of the key
    • Duplication of the key production process
  • Asymmetric encryption is much more popular as it is virtually impossible to break
    Each person has a key pair, a public key which is available to the public, and a private key, which is only held by the person themselves
    If you were to send someone a message, you would encrypt it using their public key, send it, and then they would decrypt it using their private key
  • Hashing is a function that transforms a string of characters into a fixed-length value or key that represents the original input
    You can never get the original message back after hashing, even with the algorithm
    Ideal for storing passwords so they cannot be stolen
    Also used for quick searching, insertion, and deletion of data from a data structure