Computer Science
Encryption
Caesar cipher = shift all letters by certain number of places in alphabet
Vernam cipher = create a key of random 0s and 1s; if plaintext and key digits are the same
then ciphertext is a 0, if they are different then ciphertext is a 1
Substitution cipher = a method of encrypting by which units of plaintext are replaced with
ciphertext according to a fixed system.
Transposition cipher = rearranging letters of plaintext
Frequency analysis considers how often a letter occurs in normal text and correlates this to
the ciphertext units to decipher substitution cipher
Key = a piece of information used in combination with an algorithm (cipher) to form
ciphertext from plaintext and vice versa
Number Systems and General Number Bases
Natural numbers = positive integers
Integers = numbers that can be written without a fractional counterpart
Rational numbers = numbers that can be represented as a/b where a and b are integers and
b≠0
Real numbers = numbers of continuous quantities that can be represented on a number line
Irrational numbers = real numbers that cannot be represented in the form a/b where a and b
are integers
Complex numbers = numbers that can be expressed in the form a+bi where a and b are real
numbers and i represents the imaginary unit
ASCII and Unicode
ASCII uses 7 bit encoding to code 128 different characters; includes English alphabet and
punctuation and digits but not emojis and other languages
Extended ASCII code is an 8-bit character set that represents 256 different characters,
making it possible to use characters such as é or ©. Extended ASCII is useful for European
languages
Unicode uses between 8 and 32 bits per character, so it can represent far more characters;
takes up more storage
A character code is a unique binary code representing a character
Ord(char) gives a character’s ASCII number
Chr(n) gives a number’s letter symbol in ASCII
(Unsigned) Binary Numbers
Base 10 to binary:
o Repeated subtraction of powers of 2
o Repeated division by 2 and reverse the remainders
An overflow error is when the answer cannot be represented in the given number of bits. It
does not matter if the addition gives too many bits as long as the number Can be
represented; just take the correct number of bits from the right.
BCD= binary coded decimal; parts of binary encoded as denary
2s Complement Binary Numbers
, 2s complement binary = place value of each column is the same as unsigned binary but left-
most column has negative value
To convert a negative number in base 10 to 2s complement binary:
o Find the positive number in binary
o Change 0s to 1s and vice versa
o Add 1 to the rightmost column
Hexadecimal
Higher information density and readability vs binary
Used in colour references, assembly language programs and error messages [memory locs]
Hexadecimal to binary
o Take each hexadecimal digit
o Interpret each one in base 10 eg. 2 is 2, F is 15
o Convert each to 4 bit binary
Binary to hexadecimal
o If the number of bits is not a multiple of 4, add 0s at the front of the data stream
o Take groups of 4 bits and convert each block of 4 bits to denary
o Interpret each of these denary numbers as a hexadecimal digit (10 is A, 11 is B, etc.)
Units of Data
1 bit = 1 binary digit
1 byte = 8 bits
1 kilobyte = 103bytes
1 megabyte = 106 bytes
1 gigabyte = 109 bytes
1 terabyte = 1012 bytes
1 kibibyte = 210 bytes
1 mebibyte = 220 bytes
1 gibibyte = 230 bytes
1 tebibyte = 240 bytes
Bits may represent an instruction, opcode & operand or an integer
Word = group of bits which can be manipulated as a single unit
Values, Datatypes and Expressions
The scope of a variable means where the variable is accessible – global vs local
Global variables are defined in the beginning of a program and are used to store values that
need to be used throughout the program
Local variables are declared inside a subroutine and used within the body of the subroutine
Local variables aid modularisation
Local variables better because easier to debug, easier to read, same name for diff variables
Datatype = an attribute given to all variables/constants that dictates how the data is to be
stored and handled
Integer = whole number
String = string of characters
Float = decimal number
Boolean = True or False
, Explicit type conversion can force a value to take on a specific datatype and as such be
manipulated with special operations for that data type
Expression = a statement that can be “evaluated” to result in a value which has a certain
datatype
Condition = an expression that has a Boolean value attached to it, which then results in
selection and some event taking place
Variable = a value that can change during the running of a program
Constant = a value that cannot change again once you have set it
Declaration = reserving a block of memory and giving it a named identifier and data type
Assignment = changing the value at a particular memory location; changing the value of the
variable
Boolean Algebra
, Simplification Laws:
A . A= A
A+ A= A
A . A=0
A+ A=1
A .1= A
A+0= A
A .0=0
A+1=1
A . B=B . A
A+ B=B+ A
A . ( B . C )=( A . B ) . C
A+ ( B+C )=( A+ B ) +C
A . ( B+C )= A . B+ A . C
A . ( A + B )= A
A+ ( A . B )= A
A+ ( B .C )= ( A +B ) . ( A+C )
XOR Laws:
A ⊕B=B ⊕ A
A ⊕ A=1
A ⊕ 0=A
A ⊕ 1= A
A ⊕B=B ⊕ A
( A ⊕ B ) ⊕C= A ⊕ ( B⊕ C )= A ⊕ B ⊕ C
A ( B⊕ C )= AB ⊕ AC
De Morgan’s Laws
( A . B )= A+ B
( A+ B)= A . B
Encryption
Caesar cipher = shift all letters by certain number of places in alphabet
Vernam cipher = create a key of random 0s and 1s; if plaintext and key digits are the same
then ciphertext is a 0, if they are different then ciphertext is a 1
Substitution cipher = a method of encrypting by which units of plaintext are replaced with
ciphertext according to a fixed system.
Transposition cipher = rearranging letters of plaintext
Frequency analysis considers how often a letter occurs in normal text and correlates this to
the ciphertext units to decipher substitution cipher
Key = a piece of information used in combination with an algorithm (cipher) to form
ciphertext from plaintext and vice versa
Number Systems and General Number Bases
Natural numbers = positive integers
Integers = numbers that can be written without a fractional counterpart
Rational numbers = numbers that can be represented as a/b where a and b are integers and
b≠0
Real numbers = numbers of continuous quantities that can be represented on a number line
Irrational numbers = real numbers that cannot be represented in the form a/b where a and b
are integers
Complex numbers = numbers that can be expressed in the form a+bi where a and b are real
numbers and i represents the imaginary unit
ASCII and Unicode
ASCII uses 7 bit encoding to code 128 different characters; includes English alphabet and
punctuation and digits but not emojis and other languages
Extended ASCII code is an 8-bit character set that represents 256 different characters,
making it possible to use characters such as é or ©. Extended ASCII is useful for European
languages
Unicode uses between 8 and 32 bits per character, so it can represent far more characters;
takes up more storage
A character code is a unique binary code representing a character
Ord(char) gives a character’s ASCII number
Chr(n) gives a number’s letter symbol in ASCII
(Unsigned) Binary Numbers
Base 10 to binary:
o Repeated subtraction of powers of 2
o Repeated division by 2 and reverse the remainders
An overflow error is when the answer cannot be represented in the given number of bits. It
does not matter if the addition gives too many bits as long as the number Can be
represented; just take the correct number of bits from the right.
BCD= binary coded decimal; parts of binary encoded as denary
2s Complement Binary Numbers
, 2s complement binary = place value of each column is the same as unsigned binary but left-
most column has negative value
To convert a negative number in base 10 to 2s complement binary:
o Find the positive number in binary
o Change 0s to 1s and vice versa
o Add 1 to the rightmost column
Hexadecimal
Higher information density and readability vs binary
Used in colour references, assembly language programs and error messages [memory locs]
Hexadecimal to binary
o Take each hexadecimal digit
o Interpret each one in base 10 eg. 2 is 2, F is 15
o Convert each to 4 bit binary
Binary to hexadecimal
o If the number of bits is not a multiple of 4, add 0s at the front of the data stream
o Take groups of 4 bits and convert each block of 4 bits to denary
o Interpret each of these denary numbers as a hexadecimal digit (10 is A, 11 is B, etc.)
Units of Data
1 bit = 1 binary digit
1 byte = 8 bits
1 kilobyte = 103bytes
1 megabyte = 106 bytes
1 gigabyte = 109 bytes
1 terabyte = 1012 bytes
1 kibibyte = 210 bytes
1 mebibyte = 220 bytes
1 gibibyte = 230 bytes
1 tebibyte = 240 bytes
Bits may represent an instruction, opcode & operand or an integer
Word = group of bits which can be manipulated as a single unit
Values, Datatypes and Expressions
The scope of a variable means where the variable is accessible – global vs local
Global variables are defined in the beginning of a program and are used to store values that
need to be used throughout the program
Local variables are declared inside a subroutine and used within the body of the subroutine
Local variables aid modularisation
Local variables better because easier to debug, easier to read, same name for diff variables
Datatype = an attribute given to all variables/constants that dictates how the data is to be
stored and handled
Integer = whole number
String = string of characters
Float = decimal number
Boolean = True or False
, Explicit type conversion can force a value to take on a specific datatype and as such be
manipulated with special operations for that data type
Expression = a statement that can be “evaluated” to result in a value which has a certain
datatype
Condition = an expression that has a Boolean value attached to it, which then results in
selection and some event taking place
Variable = a value that can change during the running of a program
Constant = a value that cannot change again once you have set it
Declaration = reserving a block of memory and giving it a named identifier and data type
Assignment = changing the value at a particular memory location; changing the value of the
variable
Boolean Algebra
, Simplification Laws:
A . A= A
A+ A= A
A . A=0
A+ A=1
A .1= A
A+0= A
A .0=0
A+1=1
A . B=B . A
A+ B=B+ A
A . ( B . C )=( A . B ) . C
A+ ( B+C )=( A+ B ) +C
A . ( B+C )= A . B+ A . C
A . ( A + B )= A
A+ ( A . B )= A
A+ ( B .C )= ( A +B ) . ( A+C )
XOR Laws:
A ⊕B=B ⊕ A
A ⊕ A=1
A ⊕ 0=A
A ⊕ 1= A
A ⊕B=B ⊕ A
( A ⊕ B ) ⊕C= A ⊕ ( B⊕ C )= A ⊕ B ⊕ C
A ( B⊕ C )= AB ⊕ AC
De Morgan’s Laws
( A . B )= A+ B
( A+ B)= A . B