Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- Charset = ?A.upto(?Z).to_a.concat(?a.upto(?z).to_a).concat(?0.upto(?9).to_a);
- def get_key
- i = 0;
- parts = [ ];
- while i < 4
- chars = Charset.sample(3).join;
- sum = chars.each_codepoint.reduce(:+);
- if Charset.include?((400+3*i - sum).chr)
- parts << chars + (400+3*i-sum).chr;
- i += 1;
- end
- end
- parts.join(?-);
- end
- puts get_key;
- rescue Exception => e
- p e;
- p e.message;
- p e.backtrace;
- ensure
- gets
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement