go-secretsafe
is a robust Go package for managing secrets securely. It provides encryption, storage, caching, and versioning capabilities for handling sensitive information in your applications.
- Features
- Project Structure
- Architecture Diagram
- Installation
- Usage
- Configuration
- API Reference
- Testing
- Contributing
- License
- Support
- Secure encryption and decryption of secrets
- Local file storage for secrets (encrypted at rest)
- In-memory caching for fast retrieval of frequently used secrets
- Versioning support for tracking changes to secrets
- Custom error types for better error handling and debugging
- Simple and intuitive API for managing secrets
- Configurable options for encryption algorithms, storage locations, and cache settings
go-secretsafe/
├── cmd/
│ └── secretsafe/
│ └── main.go # Main application entry point
├── pkg/
│ └── secretsafe/
│ ├── cache.go # In-memory cache implementation
│ ├── encryption.go # Encryption and decryption logic
│ ├── manager.go # Secret management operations
│ ├── storage.go # Local file storage for secrets
│ ├── utils/ # Utility functions and helpers
│ └── versioning.go # Version control for secrets
├── tests/ # Test files
├── LICENSE
├── README.md
├── go.mod
└── go.sum
To install go-secretsafe
, use the following command:
go get github.com/vivekjha1213/go-secretsafe
Here's a basic example of how to use go-secretsafe
:
package main
import (
"fmt"
"github.com/vivekjha1213/go-secretsafe/pkg/secretsafe"
)
func main() {
manager, err := secretsafe.NewManager()
if err != nil {
fmt.Printf("Error creating manager: %v\n", err)
return
}
// Set a secret
err = manager.SetSecret("database", "password", "mysecretpassword")
if err != nil {
fmt.Printf("Error setting secret: %v\n", err)
return
}
// Get a secret
password, err := manager.GetSecret("database", "password")
if err != nil {
fmt.Printf("Error getting secret: %v\n", err)
return
}
fmt.Printf("Retrieved password: %s\n", password)
// Delete a secret
err = manager.DeleteSecret("database", "password")
if err != nil {
fmt.Printf("Error deleting secret: %v\n", err)
return
}
fmt.Println("Secret deleted successfully")
}
go-secretsafe
can be configured with custom options:
manager, err := secretsafe.NewManager(
secretsafe.WithEncryptionAlgorithm("aes256"),
secretsafe.WithStoragePath("/path/to/secrets"),
secretsafe.WithCacheSize(100),
)
Creates a new instance of Manager with optional configuration.
Sets a secret value for the given namespace and key.
Retrieves a secret value for the given namespace and key.
Deletes a secret value for the given namespace and key.
Lists all keys in the given namespace.
Checks if a secret exists for the given namespace and key.
To run the tests for go-secretsafe
, use the following command:
go test ./...
We welcome contributions from the community. To contribute:
- Fork this repository
- Create a new branch for your feature or bug fix
- Commit your changes
- Push to your fork
- Open a pull request
Please make sure to write appropriate unit tests and follow the existing code style.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions, issues, or support requests, please:
- Check the documentation
- Search for existing issues
- Open a new issue if needed
- Contact vivekjha1213@gmail.com for further assistance
Thank you for using go-secretsafe! We hope it helps you manage your secrets securely and efficiently.