Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaron-contreras/caesar-cipher
A Ruby console application that ciphers text with "Caesar Cipher" as its encryption technique.
https://github.com/aaron-contreras/caesar-cipher
Last synced: 26 days ago
JSON representation
A Ruby console application that ciphers text with "Caesar Cipher" as its encryption technique.
- Host: GitHub
- URL: https://github.com/aaron-contreras/caesar-cipher
- Owner: aaron-contreras
- Created: 2020-05-18T01:19:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-16T23:54:34.000Z (over 4 years ago)
- Last Synced: 2024-11-12T03:44:12.447Z (about 2 months ago)
- Language: Ruby
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Caesar Cipher
## Problem solving steps
1. ### User interface
- Console application.
2. ### Inputs?
- String to be ciphered.
- Shift factor which determines the number of shifts to apply to each character.3. ### Output?
- Ciphered text as string.4. ### What needs to happen to go from input to output?
- #### Algorithm
```
# Until the user doesn't want to cipher anymore
# Get the string and shift factor from the user.
# Split the string into individual characters.
# Loop through each character.
# If the character is a letter.
# Convert the letter to its integer representation.
# Subtract the base value from the letter depending.
# Calculate the raw shifts by adding the shift factor to the letter to find the shifts from base value ('A' or 'a' or '0').
# Find the remainder of diving the "raw shifts" and the range to find the "net shifts" from the base value.
# Get the positive shift from the base value by adding the range to it and finding the remainder after dividing it by the range.
# Add the base value back to the positive shifts to get the shifted letter in its decimal representation.
# Convert the decimal representation to its string representation.
# Add the letter to the list of shifted characters being returned.
# If the character is not a letter.
# Just add the plain character to the array of shifted letters
# Convert the array of characters into a string.
# Return the shifted string.
```