Cryptography
Binary Representation
Problem Statement:
How many digits are needed to accurately represent the sum of 1010 1100 + 0101 0101?
Binary Sum
Concept:
When calculating a sum, insufficient storage space can lead to an Overflow Error.
Definition: An overflow error occurs when the computer attempts to store a value that exceeds the designated storage space.
Floating Point Representation
Accurate Fraction Representation:
Similar to regular binary numbers, fractions require an adequate number of bits to ensure accurate representation.
Roundoff Error:
Definition: An error that arises from trying to represent a number with more precision than available, leading the value to be rounded.
Image Representation
Concept of Pixels:
Images are composed of pixels.
Pixel Representation:
Example Color Values:
Pixel 1: R: 133, G: 34, B: 200
Pixel 2: R: 133, G: 32, B: 220
Pixel 3: R: 12, G: 122, B: 115
Pixel 4: R: 100, G: 200, B: 200
Pixel 5: R: 32, G: 34, B: 34
Pixel 6: R: 223, G: 200, B: 255
Pixel 7: R: 120, G: 150, B: 12
Pixel 8: R: 33, G: 0, B: 22
Pixel 9: R: 0, G: 0, B: 134
Data for Images:
There is a system for encoding images as numeric data, which can be manipulated to modify the image.
Pixel Filters
Types of Pixel Filters:
Brightness Filter:
Brightness Adjustment:
R: R + 50, G: G + 50, B: B + 50
Ensure no channel exceeds 255:
R: min(R + 50, 255), G: min(G + 50, 255), B: min(B + 50, 255)
Darkening Filter:
Darkening Adjustment:
R: R - 50, G: G - 50, B: B - 50
Ensure no channel goes below 0:
R: max(R - 50, 0), G: max(G - 50, 0), B: max(B - 50, 0)
Half Darkening Filter:
Only applies the darkening effect to half the pixels using:
R: max(R - 50, 0), G: max(G - 50, 0), B: max(B - 50, 0)
Note: The filters modify each pixel according to a specific function. Additional common filters include:
Sepia
Black and White
Inverted Color
Data Compression
Scale of Data:
There exists a significant amount of data worldwide, including historical methods such as punch cards, which were used to store information.
Purpose of Data Compression:
Enables the reduction of data size to take up less storage space.
Data Compression Process:
Encoding information utilizing fewer bits than the original representation.
Compression Algorithms:
Decrease data size for storage, which can later be decompressed for viewing.
Compression Example:
Original binary data: 1001 0011, 0010 0010, 1101 1111, 1101 0000, 0011 1111
Compressed and Decompressed format with functions.
Reasons for Compressing Data:
Save storage space.
Save on transmission time/bandwidth, leading to more efficient data transfer.
Provides fewer bits to send over the network.
Compression Trade-Offs:
Trade storage (which may be expensive and slow) for computation (which is cheaper and faster).
Example: A phone may not store a 300 GB raw movie but can decompress a 1 GB compressed movie.
How Compression Works:
Identify and find repeated patterns in the data and replace them with a placeholder.
Example of Compression Techniques
Run-Length Encoding:
Example representation of the format: HAAAAAAHAAAAAA
An encoded form might become H1A6.
Measuring Compression Efficiency:
Space savings formula:
Example calculation for space savings in Run-Length Encoding from previous examples.
Diverse Applications of Compression Algorithms:
Various algorithms serve better for different data types, e.g., JPEG for images and Run-Length Encoding for text.
Lossy Compression
Definition:
A method that involves discarding some data to create a smaller file size, often with impressive results visually.
Advantages/Disadvantages:
Pros:
Significantly smaller opposed to lossless compression.
Cons:
Decompressed data will not be precisely identical to the original, but remains close!
Common Algorithms:
JPEG: for images, MP3: for audio, MPEG-4: for video.
Finding Differences in Lossy Compression:
Demonstrated through examples of reduced file sizes, exemplifying the perceived differences by viewers.
Cryptography
Importance and Applications:
Ensuring secrecy for sensitive information such as credit card numbers, health records, passwords, and bank account details.
Functionality of Cryptography:
Involves scrambling digital information into unreadable forms; only authorized individuals can unscramble it using keys or passwords.
Encryption/Decryption Processes:
Basic Concepts:
Encrypt: To scramble data.
Decrypt: To unscramble data.
Historical Encryption Methods
Caesar Cipher:
Used by Julius Caesar for sending secret messages.
Mechanism: Shift letters of the alphabet by a set amount defined as a key.
Example:
Message: "ATTACK TONIGHT"
Key: 3 leads to the secret: "DWWDFN WRQLJKW"
Limitations of Caesar Cipher:
Generally easy to crack; only 26 possible shifts ensure vulnerability.
Modern Encryption Techniques
Current Encryption Strategies:
More complex than simplistic methods such as the Caesar cipher, involving sophisticated mathematical encryption.
Strengthening Encryption:
Moving from 40-bit to 256-bit keys significantly enhances security, with the latter providing an estimated $2^{256}$ possible keys, ensuring the computational difficulty of hacking attempts.
Types of Encryption Methods
Symmetric Encryption:
Using the same key for both encryption and decryption.
Asymmetric Encryption:
Utilizes unique keys for each function; one key for encrypting and a different key for decrypting.
Symmetric and Asymmetric Key Encryption
Symmetric Key Setup:
Both parties (Alice and Bob) agree upon a shared key securely and privately.
Asymmetric Key Execution:
Public key encryption allows Alice to encrypt a message with Bob's public key, while only Bob's private key can decrypt the reply, maintaining secure communication even in broader, less secure environments.