Skip to content

Commit

Permalink
Merge pull request #303 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 12.35.0
  • Loading branch information
andyone committed Nov 11, 2021
2 parents 53b2ecb + 932fff4 commit 7ba228c
Show file tree
Hide file tree
Showing 14 changed files with 563 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .scripts/packages.list
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* + env
* + errutil
* + events
* ! directio
* + directio
* + fmtc
* + fmtc/lscolors
* + fmtutil
Expand All @@ -35,6 +35,7 @@ L + netutil
* + progress
* + rand
* + req
* + secstr
* - signal
* + sliceutil
* + sortutil
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Changelog

### 12.35.0

* `[secstr]` New package for working with protected (secure) strings
* `[req]` Method `Query.String()` renamed to `Query.Encode()`
* `[passwd]` Added method `GenPasswordVariations` and `GenPasswordBytesVariations` for generating password variations with possible typos fixes
* `[passwd]` Added methods `HashBytes`, `CheckBytes`, `GenPasswordBytes` and `GetPasswordBytesStrength`
* `[passwd]` Method `Encrypt` marked as depricated (_use `Hash` method instead_)
* `[passwd]` Added more usage examples

### 12.34.0

* `[fsutil]` Added method `TouchFile` for creating empty files
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ deps: git-config ## Download dependencies

deps-test: git-config ## Download dependencies for tests
go get -v github.com/axw/gocov/gocov
go get -v golang.org/x/sys/unix
go get -v pkg.re/essentialkaos/check.v1

test: ## Run tests
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ go get -u pkg.re/essentialkaos/ek.v12
* [`progress`](https://pkg.re/essentialkaos/ek.v12/progress?docs) - Package provides methods and structs for creating terminal progress bar
* [`rand`](https://pkg.re/essentialkaos/ek.v12/rand?docs) - Package for generating random data
* [`req`](https://pkg.re/essentialkaos/ek.v12/req?docs) - Package simplify working with an HTTP requests
* [`secstr`](https://pkg.re/essentialkaos/ek.v12/secstr?docs) - Package provides methods and structs for working with protected (secure) strings
* [`signal`](https://pkg.re/essentialkaos/ek.v12/signal?docs) - Package provides methods for handling POSIX signals
* [`sliceutil`](https://pkg.re/essentialkaos/ek.v12/sliceutil?docs) - Package provides methods for working with slices
* [`sortutil`](https://pkg.re/essentialkaos/ek.v12/sortutil?docs) - Package provides methods for sorting slices
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.34.0"
const VERSION = "12.35.0"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
96 changes: 96 additions & 0 deletions passwd/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,56 @@ import (

// ////////////////////////////////////////////////////////////////////////////////// //

func ExampleHash() {
password, pepper := "MyPassword", "ABCD1234abcd1234"
hash, err := Hash(password, pepper)

if err != nil {
panic(err.Error())
}

fmt.Printf("Hash: %s\n", hash)
}

func ExampleHashBytes() {
password, pepper := []byte("MyPassword"), []byte("ABCD1234abcd1234")
hash, err := HashBytes(password, pepper)

if err != nil {
panic(err.Error())
}

fmt.Printf("Hash: %s\n", hash)
}

func ExampleCheck() {
password, pepper := "MyPassword", "ABCD1234abcd1234"
hash, err := Hash(password, pepper)

if err != nil {
panic(err.Error())
}

fmt.Printf("Valid: %t\n", Check(password, pepper, hash))

// Output:
// Valid: true
}

func ExampleCheckBytes() {
password, pepper := []byte("MyPassword"), []byte("ABCD1234abcd1234")
hash, err := HashBytes(password, pepper)

if err != nil {
panic(err.Error())
}

fmt.Printf("Valid: %t\n", CheckBytes(password, pepper, hash))

// Output:
// Valid: true
}

func ExampleGenPassword() {
weakPassword := GenPassword(16, STRENGTH_WEAK)
medPassword := GenPassword(16, STRENGTH_MEDIUM)
Expand All @@ -23,6 +73,16 @@ func ExampleGenPassword() {
fmt.Printf("Strong password: %s\n", strongPassword)
}

func ExampleGenPasswordBytes() {
weakPassword := GenPasswordBytes(16, STRENGTH_WEAK)
medPassword := GenPasswordBytes(16, STRENGTH_MEDIUM)
strongPassword := GenPasswordBytes(16, STRENGTH_STRONG)

fmt.Printf("Weak password: %s\n", weakPassword)
fmt.Printf("Medium password: %s\n", medPassword)
fmt.Printf("Strong password: %s\n", strongPassword)
}

func ExampleGetPasswordStrength() {
strength := GetPasswordStrength("secret1234%$")

Expand All @@ -38,3 +98,39 @@ func ExampleGetPasswordStrength() {
// Output:
// Password is ok
}

func ExampleGetPasswordBytesStrength() {
strength := GetPasswordBytesStrength([]byte("secret1234%$"))

switch strength {
case STRENGTH_STRONG:
fmt.Println("Password is strong")
case STRENGTH_MEDIUM:
fmt.Println("Password is ok")
case STRENGTH_WEAK:
fmt.Println("Password is weak")
}

// Output:
// Password is ok
}

func ExampleGenPasswordVariations() {
password := "myPassword12345"
variants := GenPasswordVariations(password)

fmt.Printf("Variants: %v\n", variants)

// Output:
// Variants: [MYpASSWORD12345 MyPassword12345 myPassword1234]
}

func ExampleGenPasswordBytesVariations() {
password := []byte("myPassword12345")
variants := GenPasswordBytesVariations(password)

fmt.Printf("Variants: %v\n", variants)

// Output:
// Variants: [[77 89 112 65 83 83 87 79 82 68 49 50 51 52 53] [77 121 80 97 115 115 119 111 114 100 49 50 51 52 53] [109 121 80 97 115 115 119 111 114 100 49 50 51 52]]
}

0 comments on commit 7ba228c

Please sign in to comment.