From: Jan Friedrich Date: 2008-11-13T00:07:21+09:00 Subject: Re: Convert text string i.e 'Peter' into integer ID Todd Benson wrote: > Unless I'm missing something here, strings are just numbers in order. > Why encode/encrypt? You're right: 'Peter'.to_i(36) # => 42681699 But you will become problems with larger strings if your dbms doesn't have integers with arbitrary length. > Most db's should handle natural keys. This is right. I don't adress the db part in my post. > If absolutely necessary to store as number strings (I can't see why), > look at #pack and #unpack. This would also not work for larger strings (see above). HTH, Jan