Created
September 20, 2012 04:29
-
-
Save arn-e/3753985 to your computer and use it in GitHub Desktop.
decrypt single key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decrypt_single_key(key,value) | |
offset,decrypted, off_i = key,[] , 1 | |
value.split('').each_with_index do |val, i| | |
val.ord >= 97 && val.ord <= 122 ? dist = (val.ord + offset % 26) : dist = val.ord | |
dist > 122 && dist!= val.ord ? (decrypted.push (122 - (26 - (dist - 122))).chr) : (decrypted.push dist.chr) | |
end | |
return decrypted.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment