github.com/hrvadl/security

Security (cryptography) labs


Keywords
cipher, cryptography, encryption, encryption-decryption, golang, rsa, security, signature
Install
go get github.com/hrvadl/security

Documentation

Security (cryptography) labs

This program can

  1. Encrypt/decrypt data using one of the following methods:

  2. Guess the key for the Cipher encoded data (lab 4).

  3. Create signature and verify it using RSA keypair (lab 5).

The app reads inputs and provides outputs to the files. But it can be easily extended to work with the stdin/stdout.

Folder structure

  • internal/sign contains app logic related for the signing/verifying signature of the file.
  • internal/cryptoalgo contains app logic related to the implementing DIY encryption algorithms.

How to run ciphers?

NOTE: Program works correcly only with latin alphabet letters, both uppercase and lowercase. It's not recommended to use cyryllic letters or any other symbols.

Make sure you have taskfile and Go installed. Then to encrypt/decrypt data using Caesar cipher from the root of the repo run:

task encrypt-caesar

It will look for in.txt and key.txt files in the static/cipher/rearrangement folder, then it will encrypt in.txt using key.txt and create encrypted.cipher.txt and decrypted.cipher.txt. The key.txt should contain only one integer digit which will be used as a key(shift). In example: echo "4" >> key.txt

To run a program, which will encrypt/decrypt data using Gamma cipher you can run:

task encrypt-gamma

It will look for in.txt files in the static/cipher/rearrangement folder, then it will encrypt in.txt and create encrypted.cipher.txt and decrypted.cipher.txt.

To run a program, which will encrypt/decrypt data using rearrangement cipher you can run:

task encrypt-rearrangement

It will look for in.txt and key.txt files in the static/cipher/rearrangement folder, then it will encrypt in.txt using key.txt and create encrypted.cipher.txt and decrypted.cipher.txt. The key.txt should contain comma separated integer list with indexes of the word. For example, to encrypt word "Kyiv" (four letter) we should provide list with four indexes echo "4,3,2,1" >> key.txt

How to create signature?

To run a program, which will create and verify signature for a given file you can run:

task sign

It will look for a file named in.txt in the static/sign folder, then sign it using a newly generated private key and then verify the signature with the pulic key. Private and public key will be also stored to the file in base64 encoded PEM format. Signed file will store as a separate file with the *.signed suffix.

❯ ls static/sign/
in.txt        in.txt.signed private.key   public.key