knowt logo

OCR A-Level Computer Science - 1.3.1: Compression, Encryption and Hashing

Algorithm: A clear step-by-step set of instructions (a way of solving a problem).

Program: The code used to implement an algorithm.

Data Compression:

Data Compression: Sending or storing data into a smaller amount of bits

Lossy Compression:

  • Inexact approximations for compressed content

  • Used in image, video, and sound files

    • e.g. JPEG, MPEG, and MP3 files

  • Can take less time than lossless, but lower quality

Lossless Compression:

  • All data is conserved

  • Redundant data is removed during compression and added back during decompression

  • Used for files where data integrity is most important

  • Uses Run-Length Encoding and Dictionary Encoding

Run-Length Encoding:

  • XXXY
    YXXY becomes 3X 2Y 2X 1Y

  • Uses binary

Dictionary Encoding:

  • Assigning a value to sections of text so that the values are shorter than the original text

Raster Image Files:

  • Each individual pixel has its own value

  • If images are enlarged, more pixels of the same quality are used which makes the quality decrease

  • e.g. JPEG, PNG, GIF

  • JPEG compression algorithm removes a certain amount of colours that can’t be seen by humans according to the QF (Quality Factor) number

Vector Image Files:

  • Vectors note lines and curves

  • If images are enlarged, so are the lines and curves which retain the image quality

  • e.g. SVG, EPG, AI, PDF

Data Encryption

Symmetric Encryption:

  • 1 private key is used for both encryption and decryption

  • Used for backing up hard drives

  • Can be fairly insecure as if the key is gained, messages are easily read - interceptable key

  • Send messages fairly quickly

  • Keys have to be exchanged prior to using this encryption

Asymmetric Encryption:

  • 1 public key used for encryption

  • 1 private key used for decryption

  • The same person creates both keys

  • Used for sending messages, emails and files

  • Having 2 keys makes this very secure

  • Can take longer to encrypt and send

  • You can ensure that only the intended sender will get the message

Authentication:

  • Real-life implementation of asymmetric encryption

  • The message gets encrypted by the sender’s private key.

  • The message then gets encrypted by the receiver’s private key.

  • The encrypted message is received.

  • The message gets decrypted by the receiver’s private key.

  • The message gets decrypted by the sender’s public key.

  • Messages are decrypted in the opposite order of keys as they are encrypted.

  • You can verify if it is sent or received by the intended person

Hashing:

  • Turns text or files into a hash

  • A hash is a hexadecimal

  • Hashes cannot be turned back into the original text / file

  • Can be used to transfer large amounts of data to check if it is compromised

  • Hashes are usually smaller than the original data (with the exception of some passwords)

Passwords:

  • Can be stored via plain text or hash

  • Plain text is incredibly insecure as if the data is hacked, there is no encryption

  • For authentication, the entered hash is checked if it matches the stored hash

  • Duplicate hashes for different logins are set as different hashes

Collisions

  • Occur if 2 different values have the same hash output from the hash function

T

OCR A-Level Computer Science - 1.3.1: Compression, Encryption and Hashing

Algorithm: A clear step-by-step set of instructions (a way of solving a problem).

Program: The code used to implement an algorithm.

Data Compression:

Data Compression: Sending or storing data into a smaller amount of bits

Lossy Compression:

  • Inexact approximations for compressed content

  • Used in image, video, and sound files

    • e.g. JPEG, MPEG, and MP3 files

  • Can take less time than lossless, but lower quality

Lossless Compression:

  • All data is conserved

  • Redundant data is removed during compression and added back during decompression

  • Used for files where data integrity is most important

  • Uses Run-Length Encoding and Dictionary Encoding

Run-Length Encoding:

  • XXXY
    YXXY becomes 3X 2Y 2X 1Y

  • Uses binary

Dictionary Encoding:

  • Assigning a value to sections of text so that the values are shorter than the original text

Raster Image Files:

  • Each individual pixel has its own value

  • If images are enlarged, more pixels of the same quality are used which makes the quality decrease

  • e.g. JPEG, PNG, GIF

  • JPEG compression algorithm removes a certain amount of colours that can’t be seen by humans according to the QF (Quality Factor) number

Vector Image Files:

  • Vectors note lines and curves

  • If images are enlarged, so are the lines and curves which retain the image quality

  • e.g. SVG, EPG, AI, PDF

Data Encryption

Symmetric Encryption:

  • 1 private key is used for both encryption and decryption

  • Used for backing up hard drives

  • Can be fairly insecure as if the key is gained, messages are easily read - interceptable key

  • Send messages fairly quickly

  • Keys have to be exchanged prior to using this encryption

Asymmetric Encryption:

  • 1 public key used for encryption

  • 1 private key used for decryption

  • The same person creates both keys

  • Used for sending messages, emails and files

  • Having 2 keys makes this very secure

  • Can take longer to encrypt and send

  • You can ensure that only the intended sender will get the message

Authentication:

  • Real-life implementation of asymmetric encryption

  • The message gets encrypted by the sender’s private key.

  • The message then gets encrypted by the receiver’s private key.

  • The encrypted message is received.

  • The message gets decrypted by the receiver’s private key.

  • The message gets decrypted by the sender’s public key.

  • Messages are decrypted in the opposite order of keys as they are encrypted.

  • You can verify if it is sent or received by the intended person

Hashing:

  • Turns text or files into a hash

  • A hash is a hexadecimal

  • Hashes cannot be turned back into the original text / file

  • Can be used to transfer large amounts of data to check if it is compromised

  • Hashes are usually smaller than the original data (with the exception of some passwords)

Passwords:

  • Can be stored via plain text or hash

  • Plain text is incredibly insecure as if the data is hacked, there is no encryption

  • For authentication, the entered hash is checked if it matches the stored hash

  • Duplicate hashes for different logins are set as different hashes

Collisions

  • Occur if 2 different values have the same hash output from the hash function