Here are some of the projects that I did as part of the cryptography course1 in university. Perhaps, someone may find those useful.
First and foremost, the basic Caesar cipher task with a bit of a caveat:
Write a program that implements Caesar cipher. Next, given an encrypted Ukrainian text, find a key using the estimate of the logarithmic likelihood function and decrypt it. Plot the log-likelihood function.
I used go-echarts to plot the function, it looks something like this:
To generate the HTML document from the screenshot, you can run
go run main.go caesar.go log.go chart.go
It is another historic cipher that is essentially running several Caesar ciphers according to the key. The task was to crack it by determining the key length using the Friedman test and then find the key content (I used the fact that space is the most frequent character in the Ukrainian text).
Next task was to implement a simplistic algorithm somewhat resembling DES. It was described as such:
To see it in action, you can run
go run main.go keygen.go sdes.go
An implementation of the famous Soviet algorithm and its modes of operation.
An implementation of a simplistic stream cipher based on LFSR.
Here is a picture of a 16-bit LFSR with a polynomial lfsr/lfsr.go
:
var start, polynomial uint64 = 0xACE1, 0b1000000000101101
You can modify the code slightly (lol) or use a debugger to verify that 0xACE1
state is followed by 0x5670
, as it should, or convey other tests that you prefer.
To see file encryption and decryption, just run
go run lfsr.go
There was such a task:
Write a CLI tool that implements a hashing algorithm in your preferred programming language.
Algorithm | Message source | Input | Output |
---|---|---|---|
SHA-1 | File | Hex | Hash (in hex) |
You can build it or just run
go run main.go password.txt
Footnotes
-
Криптографічні системи захисту інформації, i.e. Cryptographic information security systems ↩