twik-ruby/lib/twik/private_key.rb

16 lines
323 B
Ruby
Raw Normal View History

2014-10-21 09:23:37 +02:00
class Twik
class PrivateKey
def self.generate
format = [8, 4, 4, 4, 12]
separator = '-'
chars = ('A'..'Z').to_a + ('0'..'9').to_a
format.map do |i|
i.times.inject('') do |res, j|
res + chars[Random.rand(chars.length)]
end
end.join(separator)
end
end
end