Module: Kgl
- Defined in:
- lib/kgl.rb,
lib/kgl/version.rb
Defined Under Namespace
Modules: SuuMod
Constant Summary collapse
- VERSION =
'0.0.9'
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 nn = ((255+128)*n).ceildiv(m) begin ary = `openssl rand #{nn}`.bytes.select{ |i| i < m } nn += n end while ary.size < n ary[...n].map{ |i| ls[i] }.join rescue Errno::ENOENT => e raise 'Kgl.#rpw requires openssl command' end |