Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saro0307/password-gen
A simple password generator created using Golang
https://github.com/saro0307/password-gen
golang golang-application golang-package password password-generator
Last synced: about 2 months ago
JSON representation
A simple password generator created using Golang
- Host: GitHub
- URL: https://github.com/saro0307/password-gen
- Owner: saro0307
- License: mit
- Created: 2024-06-19T15:45:01.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-19T15:51:53.000Z (7 months ago)
- Last Synced: 2024-07-14T09:12:01.733Z (6 months ago)
- Topics: golang, golang-application, golang-package, password, password-generator
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Password Generator
A simple Golang program to generate random passwords.
## Description
This program generates a random password with a specified length and a combination of lowercase letters, uppercase letters, digits, and special characters. It uses cryptographic random number generation to ensure the password's randomness.
## Features
- Generate random passwords
- Include lowercase letters, uppercase letters, digits, and special characters
- Cryptographically secure random number generation## Usage
1. Clone the repository:
```sh
git clone https://github.com/saro0307/password-generator
```2. Navigate to the project directory:
```sh
cd password-generator
```3. Run the program:
```sh
go run passwordgen.go
```4. The generated password will be printed into the console.
## Customization
You can customize the program by editing the `passwordgen.go` file:
- Change the length of the password by modifying the `passwordLength` variable.
- Modify the character sets (`lowercase`, `uppercase`, `digits`, `special`) to include or exclude specific characters.## Example
```go
package mainimport (
"crypto/rand"
"fmt"
"math/big"
)func main() {
// Define the length of the password
passwordLength := 12// Define character sets
lowercase := "abcdefghijklmnopqrstuvwxyz"
uppercase := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
digits := "0123456789"
special := "!@#$%^&*()-_+=<>?"// Combine all character sets
allCharacters := lowercase + uppercase + digits + special// Generate password
password := generatePassword(passwordLength, allCharacters)// Print the generated password
fmt.Println("Generated Password:", password)
}func generatePassword(length int, characters string) string {
password := make([]byte, length)
charSetLength := big.NewInt(int64(len(characters)))for i := range password {
// Generate a random index
randomIndex, err := rand.Int(rand.Reader, charSetLength)
if err != nil {
fmt.Println("Error generating random index:", err)
return ""
}// Select the character from the character set
password[i] = characters[randomIndex.Int64()]
}return string(password)
}
```## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Author
- [GitHub](https://github.com/saro0307)