1.3.1 Compression, Encryption and Hashing Flashcards

(a) Lossy vs Lossless compression. (b) Run length encoding and dictionary coding for lossless compression. (c) Symmetric and asymmetric encryption. (d) Different uses of hashing.

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the current need of compression?

A

Internet service providers and mobile networks set limits and charges on bandwidth so the reduction of file sizes is important to ensure that people can view more with the limited amount of bandwidth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Lossy compression?

A

Lossy compression is an algorithm where in order to reduce the size of a file, non essential data is removed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an advantage of file compression?

A

Files will download quicker and use less of the users bandwidth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Lossless compression?

A

Lossless compression works by recording the patterns in data rather than recording the data itself, using the patterns and the instructions on how to use them, a computer can reproduce the exact data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Whats the difference between Lossy and Lossless compression?

A

Lossy compression takes away some of the data from the original. Lossless preserves all the information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why might Lossy compression be inappropriate in the compression of a text file?

A

Data lost from a text file may render it unreadable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are two examples of Lossless compression techniques?

A

RLE (Run Length Encoding) and Dictionary-Based Compression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is RLE and how does it work?

A

Run length encoding is a type of lossless compression where rather than recording every item in a sequence, it simply records the value and the number of time it repeats.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why would RLE be inappropriate for this string, QWERTYUIOPASDFGHJKLZXCVBNM?

A

Run Length encoding relies on consecutive pieces of data being the same in order to work best. Therefore RLE would not work great with that string as there are no repeats of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is RLE best for? and what is it not suited to?

A

RLE works best for simple images where there a lots of repeated colors, It does not work as great for natural language due to lack of repeating data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Dictionary-Based compression and how does it work? (Including decompression)

A

In dictionary encoding frequently occurring groups of characters are replaced by symbols/tokens which represent the longer groups of characters. A dictionary is then used to say which symbols/tokens/ match which groups of characters. When decompressed the dictionary is used to replace the tokens/symbols with the original text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What technique would be most suitable to compress the following and why?, “What’s in a name? that which we call a rose By any other name would smell as sweet; So Romeo would, were he not Romeo call’d,”

A

Dictionary-Based compression because there a lots of repeated groups of characters, for example “name”, “Romeo”, “SPACE”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Demonstrate how you could compress the following using Dictionary-Based compression. ““Nory was a Catholic because her mother was a Catholic, and Nory’s mother was a Catholic because her father was a Catholic, and her father was a Catholic because his mother was a Catholic, or had been.””

A

Firstly I counted the frequency of the character groups and SPACE had a frequency of 36, “a” was repeated 6 times and “was” was also repeated 6 times. So to ill assign SPACE to 1, “a” to 2 and “was” to 3. Nory1321Catholic1because1her1mother1321Catholic etc etc.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is Lossy compression more suited to photographs than Lossless compression?

A

When compressing a photograph some loss of detail is acceptable as the image will still be recognisable and the loss of detail is likely not going to be noticeable. Lossy compression also makes the file smaller than Lossless.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the Vernam cipher?

A

The Vernam Cipher was invented in 1917 by Gilbert Vernam and is proven to be unbreakable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define encryption.

A

Encryption is the transformation of data from one form to another to prevent unauthorised third party viewings.

17
Q

What is plain text?

A

Plain text is the original data or message before it has been encrypted.

18
Q

What is ciphertext?

A

Cipher text refers to the encrypted data.

19
Q

Define a cipher.

A

A cipher is the encryption method or algorithm used to encrypt data.

20
Q

What is an example of a substitution cipher?

A

A Caeser Cipher.

21
Q

What is private key encryption?

A

Private key encryption is symmetric encryption where the key is used to both encrypt and decrypt the ciphertext, this means the key must be transferred in key exchange to the same destination as the cipher text.

22
Q

Whats the issue with symmetric encryption?

A

Since the same key is used to both decrypt and encrypt data, a malicious third party could simply intercept the key and view the data.

23
Q

What is public key encryption?

A

Asymmetric encryption uses two separate keys to encrypt and decrypt data, the public key is used to encrypt data to allow anyone to send you data encrypted, the other key is a private key that only you have, this can be used to decrypt the data and its practically impossible to deduce the private key from the public key.

24
Q

What is a hash?

A

A result generated by applying an algorithm

process to a value.

25
Q

How does a digital signature work?

A

The sender of the message uses their own private key to encrypt the hash total, this is the digital signature, the signature is then attached to the message being sent and the whole message is encrypted using the public key of the recipient including the digital signature. When the recipient decrypts the message using their private key and decrypts the digital signature using the senders public key. The hash total is then reproduced based on the message data and if this matches the digital signature then its certain that the message came from the sender.

26
Q

Whats an advantage of storing sensitive data as a hash?

A

Hash functions are one way and cannot be reversed so if someone gained access to a data base they would not be able to access the sensitive data.

27
Q

What is an advantage of Lossy compression?

A

The advantage is that with lossy compression, you can typically achieve a far better compression ratio as compared with lossless.

28
Q

Write a pseudo code representation of how a password might work being stored as a hash.

A
temp == hash(UserEnteredPassword)
if temp == PasswordHash then
            print ("Access granted")
else
            print("Access denied")
endif
29
Q

Write a pseudocode representation of RLE for an image.

A
set color to 0
set count to 0
for each pixel in the image
     if current pixel color not equal to color then
     write count
     set color to current pixel color
     set count to 1
     else 
            increment count by 1