# File lib/simp/cli/lib/utils.rb, line 93
  def generate_password(length = DEFAULT_PASSWORD_LENGTH, default_is_autogenerate = true)
    password = ''
    if Utils.yes_or_no('Do you want to autogenerate the password?', default_is_autogenerate )
      special_chars = ['#','%','&','*','+','-','.',':','@']
      symbols = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a
      Integer(length).times { |i| password += (symbols + special_chars)[rand((symbols.length-1 + special_chars.length-1))] }
      # Ensure that the password does not start or end with a special
      # character.
      special_chars.include?(password[0].chr) and password[0] = symbols[rand(symbols.length-1)]
      special_chars.include?(password[password.length-1].chr) and password[password.length-1] = symbols[rand(symbols.length-1)]
      puts "Your password is:\n#{password}"
      print 'Push [ENTER] to continue.'
      $stdout.flush
      $stdin.gets
    else
      password = Utils.get_password
    end
    password
  end