module Backend::Password extend self DEFAULT_LEN = 10_u32 DEFAULT_CHARSET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', } def generate(len : UInt32) : String String.build(len) do |s| len.times do c = DEFAULT_CHARSET.sample(Random::Secure) s << (((Random::Secure.rand(UInt8) & 1) == 1) ? c.upcase : c) end end end end