From: James Edward Gray II Date: 2004-09-28T09:33:16+09:00 Subject: Re: {newb} Each statements On Sep 27, 2004, at 7:23 PM, STEPHEN BECKER I V wrote: > ven.rb:27:in `encrypt': undefined method `-' for "a":String > (NoMethodError) > from ven.rb:27:in `map' > from ven.rb:27:in `encrypt' > from ven.rb:38 > still split() takes one String and makes many out of it. You are trying to use those Strings as characters. See comment below... > ############33here is my code complete its some cipher > > def decrypt(data) > ndata=data.clone > srand(5000) > a = ndata.size-1 # control loop > while a>-1 > temp=ndata[a] > temp-=rand(10) > temp= 26-((temp.abs)%26) if temp<0 > temp= temp%26 if temp>-1 > ndata[a]=temp+97 > > a-=1 > > end > return ndata > > end > > def encrypt(data) > ndata=data.dup > a = ndata.size-1 > srand(5000) > ndata = ndata.split(//).map{ |c| ((c-97)+rand(10))%26 }.join > #suggested ndata = ndata.split(//).map{ |c| ((c[0]-97)+rand(10))%26 }.join > code > > #end # this code down here works but its to messy > # while a>-1 > # ndata[a]= > ((ndata[a]-97)+rand(10))%26 > # a-=1 > #end > return ndata > end > it=String.new("abcdefghijklmnop") > > print decrypt(encrypt(it)) > ################### Hope that helps. James Edward Gray II