commit ceffe3c30f0b461801108a3e0daa0040031a5830 Author: Martin Donnelly Date: Fri Feb 16 11:14:25 2024 +0000 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5d7bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,90 @@ +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Go template +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..fe5eeea --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module password + +go 1.21.4 + +require github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 + +require github.com/pwaller/goupx v0.0.0-20160623083017-1d58e01d5ce2 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a6edd63 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA= +github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pwaller/goupx v0.0.0-20160623083017-1d58e01d5ce2 h1:jqseQkFFoC94bolcHt7j90VPTgVetWlQeqFZoXN+Y2U= +github.com/pwaller/goupx v0.0.0-20160623083017-1d58e01d5ce2/go.mod h1:XO/Ely/VDivCoLQzV3hMz5dN1y6OAXUEPTwYPWQagS0= +github.com/stretchr/testify v1.1.4 h1:ToftOQTytwshuOSj6bDSolVUa3GINfJP/fg3OkkOzQQ= +github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/password b/password new file mode 100755 index 0000000..08b108f Binary files /dev/null and b/password differ diff --git a/password.go b/password.go new file mode 100644 index 0000000..441cb6e --- /dev/null +++ b/password.go @@ -0,0 +1,118 @@ +package main + +import ( + "fmt" + "math/rand" + "strings" + "time" + "github.com/nbutton23/zxcvbn-go" +) + +var alpha = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", + "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} + +var whitespace = []string{".", "!", "+", "-", "_", "*"} + +var numbers = []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "C", "X", "V", "F", "Q", "Z", "N"} + +var left = []string{"Alabama", "Alaska", "Arizona", "Maryland", "Nevada", "Mexico", "Texas", "Utah", "Glasgow", "Inverness", "Edinburgh", "Dumbarton", + "Balloch", "Renton", "Cardross", "Dundee", "Paisley", + "Hamilton", "Greenock", "Falkirk", + "Irvine", + "Renfrew", + "Erskine", + "London", + "Hammersmith", + "Islington", + "Silver", "Black", "Yellow", "Purple", "White", "Pink", "Red", "Orange", "Brown", "Green", "Blue", "Amber", "Aqua", + "Azure", "Bronze", "Coral", "Copper", "Crimson", "Cyan", "Ginger", "Gold", "Indigo", "Jade", "Ruby", "Cedar", "Cream", "Peach", "Sepcia", + + "Mercyful", "Cyber", "Ultra", "Hunter", "Electric", "Steel", "Fire", "Smoke", "Thunder", "Pewter", "Stone", "Iron", "Shadow", "Grey", "Mocha", + "Wood", "Space", "Manic", "Grunt", "X-Ray", "Sabbra", "Atomic", "Swordfish", "Dance", "Tank", + "Lazy", "Glorious", + "Abstract", "Abyssal", "Airborne", "Ancestral", "Blazing", "Bright", "Burning", "Colourless", + "Crystal", "Deadly", "Exhausted", "Favourite", "Final", "Floating", "Flying", "Frozen", + "Geometric", "Gravity", "Halcyon", "Hyper", "Infinite", "Inspiring", "Limitless", "Lucent", + "Luminous", "Magnificent", "Parallax", "Prime", "Radiant", "Raging", "Rebuilt", "Reckless", + "Relentless", "Ruthless", "Second", "Serene", "Shimmering", "Soaring", "Speedy", "Stellar", + "Swift", "Timeless", "Towering", "Tranquil", "Ultimate", "Visionary", "Whispering", "Winged"} + +var right = []string{"Aganju", "Cygni", "Akeron", "Antares", "Aragoth", "Ardus", "Carpenter", "Cooper", "Dahin", "Capella", "Endriago", "Gallina", + "Fenris", "Freya", "Glenn", "Grissom", "Jotunheim", "Lagarto", "Primus", "Vega", "Ragnarok", "Shepard", + "Slayton", "Tarsis", "Mercury", "Venus", "Mars", "Earth", "Terra", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "Europa", "Ganymede", + "Callisto", "Titan", "Juno", "Eridanus", "Scorpius", "Crux", "Cancer", "Taurus", "Lyra", "Andromeda", "Virgo", "Aquarius", "Cygnus", "Corvus", + "Taurus", "Draco", "Perseus", "Pegasus", "Gemini", "Columbia", "Bootes", "Orion", "Deneb", "Merope", "Agate", "Amber", "Beryl", "Calcite", + "Citrine", "Coral", "Diamond", "Emerald", "Garnet", "Jade", "Lapis", "Moonstone", "Obsidian", "Onyx", "Opal", "Pearl", "Quartz", "Ruby", + "Sapphire", "Topaz", "Iron", "Lead", "Nickel", "Copper", "Zinc", "Tin", "Manes", "Argon", "Neon", "Alpha", "Bravo", "Charlie", "Delta", + "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", + "Tango", "Uniform", "Victor", "Whisky", "Xray", "Yankee", "Zulu", "Fate", "Miner", "Blaster", "Click", "Noise", "Cadabra", "Shotgun", + "Swordfish", "Dancer", "Dragon", "Lotus", "Storm", + "Songbird", "Purpose", + "Aegis", "Anvil", "Ashes", "Bard", "Breath", "Claws", "Departure", "Eagle", "Falcon", "Focus", + "Forge", "Hammer", "Hand", "Hawk", "Marvel", "Master", "Mirror", "Nemesis", "Omen", "Pillar", + "Pride", "Prophecy", "Reflection", "Shield", "Skylark", "Spear", "Sword", "Talon", "Triumph", + "Victory", "Vision"} + +func randomVal(slice []string) string { + rand.Seed(time.Now().UnixNano()) + m := len(slice) + mn := 0; + + v := rand.Intn(m-mn) + mn + + outval := slice[v] + + return outval + +} + + +func numberCluster(count int, slice []string) string { + builder := []string{} + + for i:= 0; i < count; i++ { + builder = append(builder, randomVal(slice)) + } + + output := strings.Join(builder, "") + + return output +} + +func main() { + ws := randomVal(whitespace) + + long := []string{} + short := []string{} + + long = append(long, randomVal(left)) + long = append(long, randomVal(right)) + long = append(long, numberCluster(3, numbers)) + + short = append(short, numberCluster(8, alpha)) + + longOutput := strings.Join(long, ws) + shortOutput := strings.Join(short, ws) + + fmt.Printf("Long Password: %s\n\n", longOutput) + + passwordStenght := zxcvbn.PasswordStrength(longOutput, nil) + + fmt.Printf("Password score (0-4): %d\nEstimated entropy (bit): %f\nEstimated time to crack: %s\n\n", + passwordStenght.Score, + passwordStenght.Entropy, + passwordStenght.CrackTimeDisplay, + ) + + fmt.Printf("Short Password: %s\n\n", shortOutput) + + passwordStenght = zxcvbn.PasswordStrength(shortOutput, nil) + + fmt.Printf("Password score (0-4): %d\nEstimated entropy (bit): %f\nEstimated time to crack: %s\n\n", + passwordStenght.Score, + passwordStenght.Entropy, + passwordStenght.CrackTimeDisplay, + ) + +} \ No newline at end of file