Compilers and Data Types

_Harvard CS50


Cypher Text

Cypher text is the result of encrypting text into something non human-readable.
An example of Cypher text is:
UIJT XBT DT50
The above cypher text is using something known as Caesar Cypher and by shifting the characters over in the English alphabet you can get.

THIS WAS CS50

This cypher text is not considered particular strong, and can be broken easily and can be decrypted by:

  1. Frequency analysis - counting the number of times each letter appears in the ciphertext and comparing those frequencies to the frequencies of letters in the English language.

  2. Brute force attack - trying every possible combination of letters until the correct solution is found.

  3. Dictionary attack - using a list of known words to try and decrypt the ciphertext by substituting each letter for a letter in one of the known words.

  4. Known plaintext attack - if some of the plaintext is known, it can be used to try and guess the key used for encryption.

  5. Differential cryptanalysis - uses differences between different possible keys to try and determine which key was used for encryption.

CLANG (C Lang)

CLANG is a compiler for C code, this is used by the make function, make uses CLANG to compile a program without requiring the user to run multiple command-line-arguments to compile code.

An example of a command-line input to run CLANG and compile a program
clang -o hello hello.c -lcs50

Debuggers

A debugger is a piece of software that can run through code line by line at human readable speed, this allows the programmer to follow along with the code while it is running and locate mistakes easily.

Primitive Data Types

Primitive data types include:

Strings

A string, unlike other data types, does not have a set size.
Instead, a string is the size of it's contents; lets say your have a string that contains "Hi!" this string will take up 3 bytes for the characters H, I and !, but will additionally take up one more bit for a special character "/0" or 0 in binary. this character tells the computer that it has reached the end of the string.

Now knowing this, the before mentioned string "Hi!" is using 4 bytes

H i ! /0

Arrays

Arrays are a way of storing data back-to-back-to-back in a computer with an easy way of accessing this data.

Below is an example of an array
values: ["value1", "value2", "value3"]

to access the values of the array:

values[0] - (value1)
values[1] - (value2)
etc…

arrays can then be used in code such as the following:

var = ["Ben", "Josh", "Jessica", "Jemima"]
for (i in var):
	print("Hello " + i + "!")

in the above code, we are using i to iterate over each object in the array, greeting each person.