Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewhrit committed Dec 19, 2022
0 parents commit b8c0d40
Show file tree
Hide file tree
Showing 9 changed files with 2,514 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Luke Whritenour

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.
Empty file added Makefile
Empty file.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# phrase

phrase is a simple library that generates [passphrases](https://www.explainxkcd.com/wiki/index.php/936:_Password_Strength) using pure Go and a customizable dictionary.

**The default dictionary that ships with phrase is not large; some 2300 words. This is probably not a big enough data set for secure passwords. Because of that, you should consider implementing a [custom dictionary](#dictionary) before using this for passwords.**

## Documentation

### Installation

```
go get github.com/lukewhrit/phrase
```

### Basic Example

```go
package main

import "github.com/lukewhrit/phrase"

// Use the default dictionary
var p = phrase.Default

func main() {
p.Generate(3) // => ["enrage", "juice", "await"]
p.Generate(3).String() // => "trimmer-gothic-uncle"
}
```

### Dictionary

A dictionary is an array of strings with one additional function (which itself has another function), `Generate()`. Generate takes one parameter and returns an array of randomly-generated strings. The parameter being `words`, an integer, which dictates how long the returned array will be.

This library provides a default dictionary which is good enough for most (unsecure) purposes, it is available under the `Default` name (`phrase.Default`). From this dictionary, all normal functions and behaviors are available; no special conditions.

To create a custom dictionary (which you should be doing if you're generating passwords), simply define a new variable using the `phrase.Dictionary` type! A dictionary is a plain-old array of strings (literally `[]string`). If you need to programmatically create this array, say if you want to read from a file, you can easily populate it using any function (as long as it's called before `Generate()` is used), and the `append` built-in.

Something along the lines of:

```go
package main

var p Dictionary

func init() {
p = append(p, "a")
p = append(p, "b")
p = append(p, "c")
}

func main() {
Default.Generate(2) // => ["a", "c", "b"]
Default.Generate(2).String() // => "b-a-c"
}
```

## Credits and License

MIT License (c) 2022 Luke Whritenour. See [`LICENSE`](LICENSE).

The world list is graciously taken from [correcthorse by Nicolás Bevacqua](https://github.com/bevacqua/correcthorse), also under the MIT license.
Loading

0 comments on commit b8c0d40

Please sign in to comment.