Skip to content

Instantly share code, notes, and snippets.

View erbesharat's full-sized avatar
:bowtie:
Partying with Gophers

Erfan Besharat erbesharat

:bowtie:
Partying with Gophers
View GitHub Profile
@erbesharat
erbesharat / caesar_ruby.rb
Created October 6, 2016 11:03
Caesar cipher - Ruby
def caesar(text,key)
asc = text.chars.map { |c| c.ord}
shifted = asc.map { |c| c + key.to_i}
return shifted.map { |c| c.chr }.join
end
puts caesar("Erfan", 5) # Should be --> Jwkfs
puts caesar("Ruby", 3) # Should be --> Uxe|
puts caesar("Rails", 2) # Should be --> Tcknu
puts caesar("Golang", 8) # Should be --> Owtivo

Keybase proof

I hereby claim:

  • I am erbesharat on github.
  • I am erbesharat (https://keybase.io/erbesharat) on keybase.
  • I have a public key whose fingerprint is D936 6E96 D771 797B C4EB E70E 748A 09D8 6094 4440

To claim this, I am signing this object: