Hi all,
Working on a homework assignment but stuck with a little bit of coding. Anybody who’s willing to help me or point me to the right direction.
Assignment is to translate a python script to a ruby script.
First the python script :
my_secret_key = 5
def decrypt ( secret_string , secret_number ) :
result = “”
for x in secret_string :
result = result+chr( ord ( x ) ^ int (secret_number) )
return result
print(my_secret_key, “is my secret key”)
print(decrypt(“alq%lv%``k%bm
lh” , my_secret_key ) )
print(“is my secret prhase”)
Now what i got so far with the Ruby script
my_secret_key = 5
def decrypt ( secret_string , secret_number )
result = “”
secret_string.each do |x|
result = result+chr{ ord ( x ) ^ int {secret_number} }
end
return result
end
puts(my_secret_key,“is my secret key”)
puts(decrypt(“alq%lv%``k%bm
lh” , my_secret_key ) )
puts(“is my secret phrase”)
I’m stuck at the decrypt key.
Please can somenone help me
Thank you
Chris