Computers

profileankit
computer_programming_2.docx

Problem 1

Given encrypted text, decipher the text using an analytical attack.

Implement your solution in the following programming languages:

C++,

C# or Objective C

F# Convert the imperative C++ style to the Functional style as much as possible

The simplest method for encrypting text is the substitution cipher. Historically this type of cipher has been used many times, and it is a good illustration of basic cryptography.

The goal of the substitution cipher is the encryption of text. We substitute each letter of the alphabet with another one.

Example:

A k

B d

C w

The letter frequency analysis is an analytical attack that exploits the weakness of the substitution cipher. The statistical properties of the plain text are preserved in the cipher, and an algorithm should be able to successfully attack it.

1. Determine the frequency of every cipher text letter

2. Determine pairs and tuples

3. If word separators have been found, blanks, commas, etc., then short words such as THE, AND, etc. can be determined fairly fast.

Relative letter frequencies of the English language

Letter

Frequency

Letter

Frequency

A

0.0817

N

0.0675

B

0.0150

O

0.0751

C

0.0278

P

0.0193

D

0.0425

Q

0.0010

E

0.1270

R

0.0599

F

0.0223

S

0.0633

G

0.0202

T

0.0906

H

0.0609

U

0.0276

I

0.0697

V

0.0098

J

0.0015

W

0.0236

K

0.0077

X

0.0015

L

0.0403

Y

0.0197

M

0.0241

Z

0.0007

Problem 2

Given a set of encrypted numbers, decrypt the numbers. Use the case of addition only.

Implement the algorithm using the following programming languages:

C++

C# or Objective C

F#

Prolog

Example Problem:

ABCD 1234

ABCD 1234

BDEF 2468

There are numerous possible solutions. Your algorithm needs to produce only one of the possible solutions. A simple but effective method is to use brute force. That is trying and testing every possible combination of numbers. This can be greatly improved by testing the first two least significant numbers.

Limit this problem to 4 digit numbers. The result of the addition can generate 5 digits.