Answer the question
In order to leave comments, you need to log in
How to set the required number of iterations?
How to set the necessary n iterations?
Here is my example:
# Функция генерирующая пароль из цифр
def passwd(n)
# n - количество символов пароля
parole = ''
nums = Array.new(50) { |i| i * 1 }
nums.each do |n| # где n нужное кол-во итераций
x = rand(nums.length)
parole += nums[x].to_s
end
end
p = passwd(2)
puts p # => выдает от 1 до 50
Answer the question
In order to leave comments, you need to log in
The misunderstanding code that passwd generates should be replaced with
SecureRandom.hex(n)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question