Module: Kgl

Defined in:
lib/kgl.rb,
lib/kgl/version.rb

Constant Summary collapse

VERSION =
'0.0.7'

Class Method Summary collapse

Class Method Details

.rpw(n, sym = '!#$%&*+,-./:;<=>?@') ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kgl.rb', line 15

module_function def rpw(n, sym='!#$%&*+,-./:;<=>?@')
	ls = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' + sym
	m = ls.length
	`openssl rand #{n}`.bytes.map do |i|
		while m <= i
			i = `openssl rand 1`.bytes[0]
		end
		ls[i]
	end.join
rescue Errno::ENOENT => e
	raise 'Kgl.#rpw requires openssl command'
end