Skip to content

A ruby implementation of the Caeser Cipher protocol that encrypts alphabetic characters using a simple uniform position shift algorithm based on positive integer keys.

Notifications You must be signed in to change notification settings

moyela/caeser_cipher_encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caeser Cipher Encryptor

This program was developed to introduce basic software encryption concepts to children or students learning basic comupter science. It accepts an input string and an encryption key and shifts each character along the index positions of the 26 English alphabet letters and returns an output string that has been character-shifted in accordance with the key.

For example, an encryption with input string: "Ant" and encryption key: 3 returns "Dqw."

This algorithm was named after Roman general Julius Caeser and emperor Augustus Caeser who both used implementations of it to secure classified correspondence. It runs on Ruby 3.2.2 and Sinatra with a Puma server.

How to run locally

To run this program locally, download this repo and install Ruby. You can find installation instructions at the offical site.

Once you have Ruby installed, open your terminal and navigate to the 'local' directory.

Run the encryption program with:

$ ruby encryptor.rb

Run the decryption program with:

$ ruby decryptor.rb

Run the encryption cracker program with:

$ ruby cracker.rb

How to deploy as a microservice

You can create a fork of this repository and add it as a source in your hosting provider or run a local server by downloading this repo. Install Ruby and run the following commands from the root of of the repo in your terminal. Use these same commands to deploy to a PAAS service like Render.

Build command:

$ bundle install

Start command:

$ bundle exec ruby start.rb

Service endpoints

Once the service is live, access the endpoints at:

Encryption:
{YOUR_URL}/encrypt
Decryption:
{YOUR_URL}/decrypt

To encrypt an input you would make a POST request to https://www.yoururl.com/encrypt with your JSON body containing your input and encryption key:

{
    "input": "Ug vium qa Igzi Abizz ivl Q'u vwb i bmzzwzqab",
    "key": 8
}

And the response body would contain:

{
    "output": "My name is Ayra Starr and I'm not a terrorist"
}

The request structure is the same to decrypt an input.

About

A ruby implementation of the Caeser Cipher protocol that encrypts alphabetic characters using a simple uniform position shift algorithm based on positive integer keys.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published