1.3.1: Compression, Encryption, and Hashing Flashcards
What is Lossy?
- Compressing files by deleting unnecessary metadata
What are the disadvantages of Lossy?
- Data is lost permanently
- Quality is sacrificed
What is an advantage of Lossy?
- File size reduces dramatically
How is Lossy implemented?
- Reducing number of colours or cropping an image
What is Lossless?
- Compressing files by temporarily reducing file size
What is an advantage of Lossless?
- No data is lost
- Quality is not sacrificed
- The original data can be retrieved
What is a disadvantage of Lossless?
- File size isn’t as reduced as with Lossy as all the original data is still present when the file is accessed
How is Lossless implemented?
- Run Length Encoding
- Dictionary Encoding
How does Run Length Encoding work?
- An algorithm will identify sequences of colours and replace them
How does Dictionary Encoding work?
- Repetitive characters or words are replaced
Where would Lossy be most beneficial?
- When uploading, downloading, or streaming off the internet
Where would Lossless be most beneficial?
- Compressing high quality photos over the internet, where the quality would be required to be uncompromised but the file would be originally too large to efficiently send over the internet
What is Run Length Encoding?
- A method of Lossless compression in which repeated values are removed and replaced with one occurrence of the data followed by the number of times it should be repeated
- Example: AAAAAABBBBBCCC could be represented as A6B5C3
What is required for Run Length Encoding to work well?
- Consecutive pieces of data being the same
- If there is little repetition, RLE doesn’t offer a great reduction in file size
What is Dictionary Encoding?
- A method of Lossless compression where frequently occurring pieces of data are replaced with an index and compressed data is stored alongside a dictionary matching frequently occurring data to an index
- The original size can be restored using the dictionary
What is Encryption?
- The process by which plaintext (data) is transformed into an unreadable file which can be deciphered using a key authorised by users
Why is Encryption used?
- To prevent unauthorised viewing of private and confidential files
- Used for protecting data when being sent across the internet
What is Symmetric Encryption?
- The process by which plaintext is encrypted is the method by which the ciphertext is decrypted
How does Symmetric Encryption work?
- Both the sender and receiver share the same private key distributed via key exchange
What is a disadvantage of Symmetric Encryption?
- Low security because of how easy it is to crack
- Even if the key doesn’t get intercepted during exchange, the patterns in the ciphertext render the scrambled message easy to crack
What is Asymmetric Encryption?
- The process of Encryption utilising 2 keys: A public and private key
How does Asymmetric Encryption work?
- The public key can be published anywhere so anyone can see
- The private key must be kept secret
- Together the keys are known as a key pair and are mathematically related to one another
What is an advantage of Asymmetric Encryption?
- A single key cannot be used to both encrypt and decrypt communication
- Messages encrypted with the recipient’s public key can only be decrypted with the recipient’s private key (that should only be in the possession of the recipient)
What is Hashing?
- The process by which an input (a ‘key’) is turned into a fixed size value (a ‘hash’) by one of many hash functions (algorithms that turn keys into hashes)
What is an advantage of Hashing?
- The output of a Hash function cannot be reversed to form the key: Useful for storing passwords
Why is Hashing useful for storing passwords?
- A password entered by a user can be hashed and checked against the key to check if it is correct, but a hacker would only gain access to the keys, which can’t be reversed to gain the passwords
What is a Hash Table?
- A data structure that holds key-value pairs
How is a Hash Table formed?
- From a bucket array and a Hash function
What are Hash Tables used for?
- Looking up data in an array in constant time
- Used extensively in situations where a lot of data needs to be stored with constant access (e.g. caches and databases)
How do Hash Tables work?
- When data needs to be inserted, it is used as the key for the Hash function and stored in the bucket corresponding to the Hash
What is a Collision?
- If two pieces of data (keys) produce the same Hash
How can Collisions be overcome?
- Storing items together in a list under the Hash value
- Using a second Hash function to generate a new Hash
What are the features of a good Hash Function?
- Low chance of collision
- Quick to calculate
- Produce an output smaller than the input provided, otherwise searching for the Hash could take longer than searching for the key
What is a Hash Total?
- A mathematical value calculated from unencrypted message data
t