From: Joey Date: 2006-08-06T03:55:14+09:00 Subject: Re: Smoking hash-ish: Letter mapping... ------=_Part_21645_4149268.1154804111735 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Maybe: encmap=Hash[*('A'..'Z').to_a.sort{rand(2)}] and Marshal.dump and Marshal.load for storing. j`ey http://www.eachmapinject.com On 8/5/06, Meino Christian Cramer wrote: > > Hi, > > for a *very* simplistic encryption program I want to build a > hash, which should be dynamically build (not hardcoded). > > The input of the method which should do the job will be a range of > any meaningful input, say: parameter 1: A and parameter 2: Z > > Then the method should create a Hash with that mapping > "A" -> "Z" > "B" -> "G" > "C" -> "T" > ... > > or in other words: > The key should follow the given range, and the values should > represent all values of that range but in random order. > > For arrays I learned a nice trick from this list: > > encmap=(A..Z).to_a.sort{rand(2)} > > but...how can I accomplish similiar for a hash ??? > > And: I sthere a simple way to store a hash in binary format and later > load that hash again into memory ? > > Nice weekend! > mcc > > > > ------=_Part_21645_4149268.1154804111735--