Compression, Encryption and Hashing
Lossy and Lossless
Compression
Reduce size of file
Reduce download times
Reduce storage requirements
Make best use of bandwidth
Reduce transmission times
It can be sent by email
Lossy Compression
Not used for files
Used for Images and video
No noticeable reduction in quality
Cannot be restored to original file size and quality; permanently deletes part of the file
Lossless Compression
Fully able to restore image in original quality when uncompressed
Only effective on images with large areas of continuous colours
Useful for vector-like images
Used for executable files and documents
Hashing
Transforms a string of characters to a fixed length value or key that represents the original input string
Popular hashes are:
SHA-1
MD5
It is a one-way process. You cannot get original value from hashed value even if you have access to the original hashing algorithm
Ideal for preventing passwords and PINs from being read by a hacker
In order to verify a user’s password, the system needs to:
Apply hashing factor to the entered password
Compare hashed value to the one stored
Can be used for quick searching, insertion, deletion of data
By hashing we can input what we are looking for and apply hashing function to find what we want
Encryption
Process of encoding a message so it can be read only by the sender and the intended recipient
Symmetric Encryption
A single key is used to both encrypt and decrypt a message. Both parties need to know the key and both need to keep it a secret.
Dangers
It can be cracked by
Interception of the key
Duplication of the key
Asymmetric Encryption
Uses 2 different keys
Unencrypted message → decrypt with 1st key
Once the message is sent, the recipient then decrypts the message with the 2nd key
It is virtually impossible to derive either key from the other key, making it a very secure form encryption
Anything encrypted with one of the keys can be decrypted with the other = key pair (public and private key)
Public key = give it out or publish online, are often stored in secure servers called key safes; anyone can access the public key
In asymmetric encryption, the public key is used to encrypt data, and the private key is used to decrypt it. The public key can be shared with anyone, while the private key is kept secret by the owner. This eliminates the need for a secure key exchange, which is a significant advantage over symmetric encryption.
For example, if Alice wants to send a secure message to Bob, she would use Bob's public key to encrypt the message. Bob would then use his private key to decrypt it. This ensures that only Bob can read the message, even if it is intercepted by a third party