1.3.1 Compression, encryption and hashing Flashcards
compression
Compression is the process used to reduce the storage space required by a file, meaning you can store more files with the same amount of storage space. Compression is particularly important for sharing files over networks or the Internet. The larger a file, the longer it takes to transfer and so compressing files increases the number of files that can be transferred in a given time.
lossy compression
-original file cannot be restored as it permanently deletes data
-Algorithm used to strip out least important data
-examples-JPEG, MP3, MPEG
-typically used for multimedia files
-images
lossless compression
-original file can be restored as it doesnt permanently delete data
-typically less effective at reducing file size
-examples- ZIP, PNG, GIF
-essential for some file types such as computer programs
-audio
Run Length Encoding
This method is ideal for compressing bitmap images, contiguous pixels of the same colour.
Sometimes called RLE, run length encoding is 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.
For example, the string AAAAAABBBBBCCC could be represented as A6B5C3.
Dictionary Coding
Works by building an index that we visualise as a table and every data or entry in the file is recorded.
Dictionary encoding is another example of a method of lossless compression. Frequently occurring pieces of data are replaced with an index and compressed data is stored alongside a dictionary which matches the frequently occurring data to an index. The original data can then be restored using the dictionary.
Run Length Encoding disadvantage
In order to work well, run length encoding relies on consecutive pieces of data being the same - if there’s little repetition, run length encoding doesn’t offer a great reduction in file size.
encryption
The process of encoding a message so it can be read only by the sender and the intended recipient.
Encryption is used to keep data secure when it’s being transmitted. There are a variety of different methods which can be used to scramble data before it’s transmitted and then decipher it once it arrives at its destination.
Symmetric Encryption
A single key is used to both encrypt and decrypt a message.
In symmetric encryption, both the sender and receiver share the same private key, which they distribute to each other in a process called a key exchange. This key is used for both encrypting and decrypting data.
It’s important that the private key is kept secret. If the key is intercepted during the key exchange then any communications sent can be intercepted and decrypted using the key. Asymmetric encryption gets around this issue.
Asymmetric Encryption
When sending information using asymmetric encryption, two keys are used: one public and a second, private, key. Something which is encrypted with one of the keys can only be decrypted with the other key. For example, if a document is encrypted with the public key, only the private key could be used to decrypt the document.
The public key can be published anywhere, free for the world to see, while the private key
must be kept secret. Together, these keys are known as a key pair.
Asymmetric encryption is based on everyone having their own key pair. They publish their
public keys online on a special website and keep their private key to themselves.
Hashing
Transforms a string of characters into a fixed-length value or key that represents the original input string.
Hashing advantage
Unlike encryption, the output of a hash function can’t be reversed to form the key. This quality makes hashing useful for storing passwords. A password entered by a user can be hashed and checked against the key to see if it is correct, but a successful hacker would only gain access to the keys, which can’t be reversed to gain the passwords.
properties of hashing
-low chance of collisions
-quick to calculate
-output smaller than input