Compression, Encryption and Hashing Flashcards

1
Q

What name is given to the public and private keys used in asymmetric encryption?

A

Key Pair

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

Name the two categories of compression:

A

Lossy and Lossless

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

In which type of compression is the quality of a file not degraded?

A

Lossless

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

What is the purpose of encryption?

A

To keep data secure during transmission

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

Name one type of lossless compression:

A

Either:

Run length encoding
Dictionary encoding

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

In which form of encryption do the sender and receiver share the same private key?

A

Symmetric encryption

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

How many keys are used in asymmetric encryption?

A

Two (one public and one private key)

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

If person A wants to send a message to person B using asymmetric encryption, which key should they use to encrypt the message?

A: A’s public key
B: A’s private key
C: B’s public key
D: B’s private key

A

C: B’s public key

A message encrypted with B’s public key can only be decrypted with B’s private key, which only B has access to

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

What is said to have occurred when two keys map to the same hash?

A

A collision

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

In which kind of lossless compression are repeated characters replaced by one occurs fr and the number of times to repeat the character?

A

Run length encoding

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

What name is given to the process of turning an input into a fixed size value?

A

Hashing

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

Which data structure uses hashing to store information with constant lookup time?

A

Hash Table

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

What is meant by compression?

A

The process of reducing the space required to store a file

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

Name two properties that a hashing algorithm should have:

A

Two from:

  • Low chance of collision
  • Quick to calculate
  • Output smaller than input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
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
16
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
17
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
18
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
19
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
20
Q

What are two examples of Lossless compression techniques?

A

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

21
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.

22
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.

23
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.

24
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.

25
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”.

26
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.”

27
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.

28
Q

What is the Vernam cipher?

A

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

29
Q

Define encryption.

A

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

30
Q

What is plain text?

A

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

31
Q

What is ciphertext?

A

Cipher text refers to the encrypted data.

32
Q

Define a cipher.

A

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

33
Q

What is an example of a substitution cipher?

A

A Caeser Cipher.

34
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.

35
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.

36
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.

37
Q

What is a hash?

A

A result generated by applying an algorithm

process to a value.

38
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.

39
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.

40
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.

41
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

42
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

43
Q

Describe two different ways that hashing could be used in a database.

A
  1. Encrypting data.
  2. Hashing for direct access.
    (Hash of an index as an address. for example:
    Customer/Room/Bookings)
44
Q

What is the hashing function?

A

Transforms a string of characters into a fixed-length value or key that represents the original input string.

Some popular hashing algorithms are:
- SHA-1
- MD5

45
Q

Why is hashing not the same as encryption?

A

The main difference is that hashing is a one-way process.
You cannot get back to the original value from the hashed value, even if you have access to the original hashing algorithm.

46
Q

When is hashing used? (LOGIN/REGISTER)

A

Hashing is ideal for preventing information like passwords and PINs from being read by a hacker.

For example:
When signing up for something, and saving the information the username will be plain text, however, the password would be in hash form. This means if a hacker gets access to the information he will not be able to see the password in plain text, but the hash and as the hash is one-way the hacker cannot obtain any actual passwords from the compromised file.

The way a user gets back into their account (as their password is saved as hash) is by hashing the entered password when logging in and comparing it to the one stored, if they are the same then they will be granted access else they would have to type the correct one in.

47
Q

How is hashing used for quick data storage and retrieval?

A

Hashing can be used for quick searching, insertion, and deletion of data from data structures.

By using hashing, there is no need to search the data structure to find an entry. An input of what is being searched for can be made, then the hashing function can be applied to the input and it would immediately find the item being searched for. The items don’t even need to be sorted

48
Q

On average what is hashing time complexity

A

O(1) - Constant Time