Hi everyone :) I''m starting in Ruby, and first I would like to translate a fonction php I made into a ruby one. In php it''s very slow due to the number of possibilities, the function is : <?php function boom($value) { $toto = "bbc4d9cb08ddbce591c28effcf6a6120005dc477"; $tabbb = array( "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); if(isset($value)){ for($i=0;$i<=25;$i++){ for($j=0;$j<=25;$j++){ for($k=0;$k<=25;$k++){ for($l=0;$l<=25;$l++){ for($m=0;$m<=25;$m++){ for($n=0;$n<=25;$n++){ for($o=0;$o<=25;$o++){ for($p=0;$p<=25;$p++){ $pass $tabbb[$i].$tabbb[$j].$tabbb[$k].$tabbb[$l].$tabbb[$m].$tabbb[$n].$tabbb[$o].$tabbb[$p]; if( (substr_replace( (sha1( strrev( md5($pass) ) )), "bb", 0, 2))==$toto ){alert($pass);} } } } } } } } } } } ?> Any idea? thx -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Avo wrote:> I''m starting in Ruby, and first I would like to translate a fonction php > I made into a ruby one. In php it''s very slow due to the number of > possibilities, the function is : > > <?php > function boom($value) { > $toto = "bbc4d9cb08ddbce591c28effcf6a6120005dc477";Get PhpUnit, and write unit tests for this function. Start with the simplest cases, such as ''A''. Then write simple unit tests in Ruby that match each input and output. "Grow" your Ruby function, by adding test cases that fail, then upgrading your function to pass. With a little perseverance, and a book on the Ruby language, you will have a rock-solid and bug-free implementation in no time. Your design might come out the same, or different. Growing your function gives you many opportunities, while it is still small, to discover alternate patterns. The tests will make refactoring to any different pattern very easy. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Avo wrote:> Hi everyone :) > > I''m starting in Ruby, and first I would like to translate a fonction php > I made into a ruby one. In php it''s very slow due to the number of > possibilities, the function is :Hi Avo. How about def boom puts "why not just ask them what their password is" end It''s the pragmatic approach and it stands a greater chance of succeeding. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Houghton wrote:> Avo wrote: >> Hi everyone :) >> >> I''m starting in Ruby, and first I would like to translate a fonction php >> I made into a ruby one. In php it''s very slow due to the number of >> possibilities, the function is : > > Hi Avo. How about > > def boom > puts "why not just ask them what their password is" > end > > It''s the pragmatic approach and it stands a greater chance of > succeeding.lol, we can call it a "challenge" :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Houghton wrote:> Avo wrote: >> Hi everyone :) >> >> I''m starting in Ruby, and first I would like to translate a fonction php >> I made into a ruby one. In php it''s very slow due to the number of >> possibilities, the function is : > > Hi Avo. How about > > def boom > puts "why not just ask them what their password is" > end > > It''s the pragmatic approach and it stands a greater chance of > succeeding. >LOL! Much cleaner too. -- Chris Martin Web Developer http://chriscodes.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Martin wrote:> Michael Houghton wrote: >> puts "why not just ask them what their password is" >> end >> >> It''s the pragmatic approach and it stands a greater chance of >> succeeding. >> > > LOL! > Much cleaner too. > > -- > Chris Martin > Web Developer > http://chriscodes.comrequire ''digest/md5'' require ''digest/sha1'' aFile = File.open "length7v.txt", "r" aFile.each do |line| md5 = Digest::MD5::hexdigest(line.chomp).reverse sha1 = "bb" + Digest::SHA1::hexdigest(md5)[2..39] puts "Testing #{line}" if sha1 == "bbc4d9cb08ddbce591c28effcf6a6120005dc477" puts "Found the pass : #{line}" system "pause" end end easy!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---