On Wed, Nov 27, 2013 at 4:11 PM, Sabin C. [email protected]
I m actually a PHP, C# programmer and thinking of getting my hands to
Ruby as well. I have 3 lines of codes that is in ruby which I need
equivalent in c#. As the question is related to ruby, I thought this
place would be a good one to post.
I don’t know C#, but I can try to explain what this does, so maybe you
can translate it yourself:
Initialize a string with those chars.
final_key = “\0” * 16
Initialize a string with 16 zeros (the byte 0)
key.length.times do |i|
once for each char in the key string:
set the character at position i modulus 16 (so you go round and round
along the string final_key) to the value calculated like so:
[…] (final_key[i%16].ord ^ key[i].ord).chr
take the byte value of that position in the string, and xor with the
byte value of the current position in the key. ord returns the byte
value of a char, and chr returns the char corresponding to a integer
value, so after xoring, you take the char that corresponds to that
value and place it in the string.
print the resulting string.