NEWBIE QUESTION - recode in Ruby

I wish to recode the following php code to ruby:

function text_decrypt_symbol($s, $i) {

$s is a text-encoded string, $i is index of 2-char code. function

returns number in range 0-255

     return (ord(substr($s, $i, 1)) - 100)*16 + ord(substr($s, $i

+1, 1)) - 100;
}

function text_decrypt($s) {

 if ($s == "")
     return $s;
 $enc = 85 ^ text_decrypt_symbol($s, 0);
 for ($i = 2; $i < strlen($s); $i+=2) { # $i=2 to skip salt
     $result .= chr(text_decrypt_symbol($s, $i) ^ $enc++);
     if ($enc > 255)
         $enc = 0;
 }
 return $result;

}

As I have stated I am a ruby newbie but thus far I have produced this:

def text_decrypt(value)
enc = 85 ^ text_decrypt_symbol(value, 0);

 i = 2

 while i < value.length
     curchar = text_decrypt_symbol(value, i) ^ enc++
     result += curchar.chr
     if enc > 255
         enc = 0
     end

     i+=2
 end
 return result;

end
def text_decrypt_symbol(value, value2)
char1 = value[value2, 1]
char2 = value[value2+1, 1]

 return (char1.chr - 100)*16 + char2.chr - 100;

end

Apparently the .chr method requires an integer to work. Anyone have
any advice?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs