Giter Club home page Giter Club logo

passgen's Introduction

Passgen

Ruby gem for generating passwords quickly and easily. Although it is suitable for use within Rails it has no Rails dependencies and can be used in non-Rails applications as well.

It can generate passwords including lower case, upper case, digits and symbols and also pronounceable passwords.

Since 1.0.0 you can also analyze the quality of a password, both as a numeric score between 0 and 100 and as a complexity ranking.

Install

gem install passgen

Usage

The usage could not be easier. Just require and call the generate method:

>> require 'rubygems'
>> require 'passgen'
>> Passgen::generate
=> "zLWCeS3xC9"

You check the strength of a password by calling analyze:

>> info = Passgen::analyze("zLWCeS3xC9")
=> #<Passgen::StrengthAnalyzer:0xb728654c @complexity="Strong", @score=78, @errors=[], @password="zLWCeS3xC9">
>> info.score
=> 78
>> info.complexity
=> "Strong"

Examples

>> Passgen::generate
=> "zLWCeS3xC9"
>> Passgen::generate(:length => 20)
=> "6lCcHvkuEW6OuzAtkoAs"
>> Passgen::generate(:symbols => true)
=> "gr)$6bIym1"
>> Passgen::generate(:lowercase => :only)
=> "ysbwuxbcea"
>> Passgen::generate(:number => 3)
=> ["REdOigTkdI", "PQu8DsV9WZ", "qptKLbw8YQ"]
>> Passgen::generate(:seed => 5)
=> "JoV9M2qjiK"
>> Passgen::generate(:seed => 5) # Will generate same password again
=> "JoV9M2qjiK"
>> Passgen::generate(:pronounceable => true) # Pronounceable, mixed case password
=> "ActeodEuRT"
>> Passgen::generate(:pronounceable => true, :lowercase => :only) # Pronounceable lower case
=> "terysolang"
>> Passgen::generate(:pronounceable => true, :uppercase => :only) # Pronounceable upper case
=> "ACTOPECHEI"
>> Passgen::generate(:pronounceable => true, :digits_before => 3) # Pad with digits in front
=> "886uRApLIN"
>> Passgen::generate(:pronounceable => true, :digits_before => 3) # Pad with digits at the end
=> "uRAPLIN886"

Options:

:lowercase => true/false/:only

  • true - Use lowercase letters in the generated password.

  • false - Do not use lowercase letters in the generated password.

  • :only - Only use lowercase letters in the generated password.

:uppercase => true/false/:only

  • true - Use uppercase letters in the generated password.

  • false - Do not use uppercase letters in the generated password.

  • :only - Only use uppercase letters in the generated password.

:digits => true/false/:only

  • true - Use digits in the generated password.

  • false - Do not use digits in the generated password.

  • :only - Only use digits in the generated password.

:symbols => true/false/:only/:list

  • true - Use symbols in the generated password.

  • false - Do not use symbols in the generated password.

  • :only - Only use symbols in the generated password.

  • :list - A string with the symbols to use. Not implemented yet.

:number => integer

Number of passwords to generate. If >1 the result is an Array.

:length => integer/range

The number of characters in the generated passwords. A range results in passwords lengths within the given range.

:seed => integer/:default

Set the srand seed to the given integer prior to generating the passwords.

:pronounceable => true/false

  • true - Generate pronounceable passwords

  • false - No effect

:digits_after => true/number (Only in combination with :pronounceable)

  • Pads the pronounceable password with number digits at the end. Defaults to 2 if true is passed.

:digits_before => true/number (Only in combination with :pronounceable)

  • Pads the pronounceable password with number digits in front. Defaults to 2 if true is passed.

Default values:

:lowercase => true

:uppercase => true

:digits => true

:symbols => false

:pronounceable => Not implemented yet.

:number => 1

:length => 10

:seed => nil

:pronounceable => false

:digits_after => 2 (Only in combination with pronounceable)

:digits_before => 2 (Only in combination with pronounceable)

Copyright and license

Copyright © 2009-2010 Erik Lindblad

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

passgen's People

Contributors

cryptice avatar rbecher avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.