From: Shannon Fang Date: 2006-04-18T03:03:55+09:00 Subject: a simple RSA Hi All, I tried to implement a simple RSA crypto for my work. It seems all works fine, except that I am not satisfied with the code I wrote below: def str_to_num(s) h = '0x' (0...s.length).each do |i| h += "%02x" % s[i] end eval(h) end def num_to_str(n) s = '' while n > 0 do s = "%c" % (n & 0xFF) + s n = n >> 8 end s end These 2 functions convert string to bignum and vise-versa. It works, but I feel there should be better (faster) way to do this. Could anyone point the way out? Thanks! Shannon