Advertisement
RedouaneRed1

random keygen

Aug 22nd, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.43 KB | None | 0 0
  1. begin
  2. Charset = ?A.upto(?Z).to_a.concat(?a.upto(?z).to_a).concat(?0.upto(?9).to_a);
  3.  
  4. def get_key
  5.     i = 0;
  6.     parts = [ ];
  7.     while i < 4
  8.         chars = Charset.sample(3).join;
  9.         sum = chars.each_codepoint.reduce(:+);
  10.         if Charset.include?((400+3*i - sum).chr)
  11.             parts << chars + (400+3*i-sum).chr;
  12.             i += 1;
  13.         end
  14.     end
  15.     parts.join(?-);
  16. end
  17.  
  18. puts get_key;
  19. rescue Exception => e
  20. p e;
  21. p e.message;
  22. p e.backtrace;
  23. ensure
  24. gets
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement