https://github.com/hrvadl/security
Security (cryptography) labs
https://github.com/hrvadl/security
cipher cryptography encryption encryption-decryption golang rsa security signature
Last synced: over 1 year ago
JSON representation
Security (cryptography) labs
- Host: GitHub
- URL: https://github.com/hrvadl/security
- Owner: hrvadl
- Created: 2024-09-06T07:46:56.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T13:26:42.000Z (over 1 year ago)
- Last Synced: 2025-01-30T12:24:45.514Z (over 1 year ago)
- Topics: cipher, cryptography, encryption, encryption-decryption, golang, rsa, security, signature
- Language: Go
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Security (cryptography) labs
This program can
1. Encrypt/decrypt data using one of the following methods:
- [Rearrangement](https://github.com/hrvadl/security/blob/master/internal/cryptoalgo/domain/cipher/rearrangement/rearrangement.go) (lab 1).
- [Caesar](https://github.com/hrvadl/security/blob/master/internal/cryptoalgo/domain/cipher/ceasar/ceasar.go) (lab 2).
- [Gamma](https://github.com/hrvadl/security/blob/master/internal/cryptoalgo/domain/cipher/gamma/cipher.go) (lab 3).
2. [Guess the key](https://github.com/hrvadl/security/blob/master/internal/cryptoalgo/domain/analysis/decrypt.go) for the Cipher encoded data (lab 4).
3. [Create signature](https://github.com/hrvadl/security/blob/master/internal/sign/domain/sign/signer.go) 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](https://github.com/hrvadl/security/tree/master/internal/sign) contains app logic related for the signing/verifying signature of the file.
- [internal/cryptoalgo](https://github.com/hrvadl/security/tree/master/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](https://taskfile.dev/) and [Go](https://go.dev/) installed. Then to encrypt/decrypt data using
Caesar cipher from the root of the repo run:
```sh
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:
```sh
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:
```sh
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:
```sh
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.
```sh
❯ ls static/sign/
in.txt in.txt.signed private.key public.key
```