Skip to content

Instantly share code, notes, and snippets.

@tomekwojcik
Created December 24, 2011 15:20
Show Gist options
  • Save tomekwojcik/1517544 to your computer and use it in GitHub Desktop.
Save tomekwojcik/1517544 to your computer and use it in GitHub Desktop.
Why The Fuck Should I Use An API For "What The Fuck Should I Use For Password"?

Why The Fuck Should I Use An API For "What The Fuck Should I Use For Password"?

What The Fuck Should I Use For Password? wouldn't be much of a Web 2.0 app if it didn't provide an API. Using this API you can get a pseudo-random string in JSON or plaintext form.

Query format

http://whatthefuckshouldiuseforpassword.com/*format*?*query_string*

Formats

There are two formats supported at the moment: json and text.

Querying

Use query_string to determine which character classes to use while generating the password and what its length should be.

Default query string is: length=8&letters=yes&digits=yes&punctuation=yes.

To enable a character class set its name to yes in query string, e.g. digits=yes. If you don't provide any character classes all of them will be enabled. Currently supported character classes are: letters, digits and punctuation.

length defaults to 8.

Responses

HTTP status code 400 means that, well, the request was bad. This is usually caused by trying to generate password longer than the charset, e.g. length=20&digits=yes is a no-no.

JSON response body

Success: { 'status': 'ok', 'fucking_password': '...' }

Error: { `status`: 'fucking_error', 'fucking_password': null }

Plaintext response body

Success: the password itself

Error: Fucking Error

Examples

http://whatthefuckshouldiuseforpassword.com/json?length=16 - all chars, 16 chars long, JSON-formatted.

http://whatthefuckshouldiuseforpassword.com/text?length=16 - all chars, 16 chars long, plaintext-formatted.

http://whatthefuckshouldiuseforpassword.com/json?length=8&digits=yes - only digits, 8 chars long, JSON-formatted.

http://whatthefuckshouldiuseforpassword.com/text?length=8&digits=yes - only digits, 8 chars long, plaintext-formatted

http://whatthefuckshouldiuseforpassword.com/json?length=24&digits=yes&letters=yes - digits + letters, 24 chars long, JSON-formatted.

http://whatthefuckshouldiuseforpassword.com/text?length=24&digits=yes&letters=yes - digits + letters, 24 chars long, plaintext-formatted

http://whatthefuckshouldiuseforpassword.com/json?length=36&punctuation=yes&letters=yes - punctuation + letters, 36 chars long, JSON-formatted.

http://whatthefuckshouldiuseforpassword.com/text?length=36&punctuation=yes&letters=yes - punctuation + letters, 36 chars long, plaintext-formatted

http://whatthefuckshouldiuseforpassword.com/json?length=128 - error, JSON-formatted.

http://whatthefuckshouldiuseforpassword.com/text?length=128 - error, plaintext-formatted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment