Permalink
Browse files

Fixed yet another challenge problem

  • Loading branch information...
1 parent 7148032 commit 386781a89260ff49687e0f57419a0d22b36157b4 Ary Borenszweig committed Nov 5, 2012
Showing with 9 additions and 1 deletion.
  1. +5 −1 lib/msn/challenge.rb
  2. +4 −0 spec/msn/challenge_spec.rb
View
@@ -37,7 +37,11 @@ def challenge(challenge, product_key = ProductKey, product_id = ProductId)
new_hash_parts[2] ^= high;
new_hash_parts[3] ^= low;
- new_hash_parts.map { |x| x.to_s(16).scan(/.{2}/).reverse.join }.join
+ new_hash_parts.map do |num|
+ str = num.to_s(16)
+ str = "#{'0' * (8 - str.length)}#{str}" if str.length != 8
+ str.scan(/.{2}/).reverse.join
+ end.join
end
end
end
@@ -12,4 +12,8 @@
it "replies to longer challenge" do
Challenge.challenge("237191752526424888127371168").should eq("65b6b623c649c25629af048d34066040")
end
+
+ it "replies to yet another challenge" do
+ Challenge.challenge("193843906697656899510167525").length.should eq(32)
+ end
end

0 comments on commit 386781a

Please sign in to comment.