簡單版本:工具
base_char = (32..126).map{|i|i.chr} - ["'",'"'," ", "`","\\"] puts (1..16).map{base_char[rand(base_char.length)]}.join
複雜版本:spa
#工具腳本,快速生成隨機密碼 base_char=[] #定義密碼基礎字符集 base_char += ('0'..'9').to_a base_char += ('a'..'z').to_a base_char += ('A'..'Z').to_a base_char += ('!'..'/').to_a base_char.delete("'") # puts base_char #密碼長度 size = 16 #生成密碼 password = (1..size).map{base_char[rand(base_char.length)]}.join puts password