Skip to content

Instantly share code, notes, and snippets.

View CharlesIvia's full-sized avatar

Charles Ivia CharlesIvia

View GitHub Profile
@matugm
matugm / caesar.rb
Last active September 16, 2023 05:23
Caesar cipher using Ruby
ALPHABET_SIZE = 26
def caesar_cipher(string)
shiftyArray = []
charLine = string.chars.map(&:ord)
shift = 1
ALPHABET_SIZE.times do |shift|
shiftyArray << charLine.map do |c|
((c + shift) < 123 ? (c + shift) : (c + shift) - 26).chr