mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-01 06:46:38 -04:00
Prepare for release v0.3.1
This commit is contained in:
@@ -131,7 +131,7 @@ func EntryAddPrecheck(targetLocation string) uint8 {
|
||||
|
||||
// StringGen generates a random string of a specified length and complexity.
|
||||
// Requires: complexity (minimum percentage of special characters to be returned in the generated string; set to 0 to generate a simple string),
|
||||
// complexCharsetLevel (0 = safe for filenames, 1 = safe for most password entries, 2 = safe only for well-made password entries)
|
||||
// complexCharsetLevel (1 = safe for filenames, 2 = safe for most password entries, 3 = safe only for well-made password entries)
|
||||
func StringGen(length int, complexity float64, complexCharsetLevel uint8) string {
|
||||
var actualSpecialChars int // track the number of special characters in the generated string
|
||||
var minSpecialChars int // track the minimum number of special characters to accept
|
||||
@@ -145,11 +145,11 @@ func StringGen(length int, complexity float64, complexCharsetLevel uint8) string
|
||||
if complexity > 0 {
|
||||
minSpecialChars = int(math.Round(float64(length) * complexity)) // determine minimum number of special characters to accept
|
||||
switch complexCharsetLevel {
|
||||
case 0:
|
||||
extendedCharset = extendedCharsetFiles
|
||||
case 1:
|
||||
extendedCharset = extendedCharsetMostPassword + extendedCharsetFiles[:len(extendedCharsetFiles)-9]
|
||||
extendedCharset = extendedCharsetFiles
|
||||
case 2:
|
||||
extendedCharset = extendedCharsetMostPassword + extendedCharsetFiles[:len(extendedCharsetFiles)-9]
|
||||
case 3:
|
||||
extendedCharset = extendedCharsetFiles + extendedCharsetMostPassword + extendedCharsetSpecialPassword
|
||||
}
|
||||
charset += extendedCharset
|
||||
|
||||
Reference in New Issue
Block a user