Function php => ruby

Hi everyone :slight_smile:

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

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!!

Avo wrote:

Hi everyone :slight_smile:

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.

Michael H. wrote:

Avo wrote:

Hi everyone :slight_smile:

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” :slight_smile:

Michael H. 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 M.
Web D.
http://chriscodes.com

Chris M. wrote:

Michael H. 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 M.
Web D.
http://chriscodes.com

require ‘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!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs