/

Secrets Manager Installation

Before you begin

You'll need:

Installation

Install the ByteHide Secrets SDK using Go modules:

Bash
go get github.com/bytehide/bytehide-secrets-go/secrets

Initialize the SDK

Once installed, you need to initialize the SDK with your project token.

Set up environment variables and the SDK will auto-initialize:

Go
package main

import (
    "fmt"
    "log"

    "github.com/bytehide/bytehide-secrets-go/secrets"
)

func main() {
    // Environment variables:
    // BYTEHIDE_SECRETS_TOKEN=f8118003-c24d-4f6f-9057-1a0d0b89ef55
    // BYTEHIDE_SECRETS_ENVIRONMENT=production

    // The SDK will read from environment variables automatically
    apiKey, err := secrets.Get("API_KEY")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("API Key:", apiKey)
}

Direct Initialization

For testing or development scenarios, you can initialize directly with a token:

Go
package main

import (
    "log"

    "github.com/bytehide/bytehide-secrets-go/secrets"
)

func main() {
    // Not recommended for production - use environment variables instead
    err := secrets.UnsecureInitialize("f8118003-c24d-4f6f-9057-1a0d0b89ef55", "production")
    if err != nil {
        log.Fatal(err)
    }
}

Security Notice

Never hardcode your token in source code. For production environments, always use environment variables or a secure vault.

Environment Variables Setup

Development Environment

Bash
# Linux/macOS
export BYTEHIDE_SECRETS_TOKEN=your-token-here
export BYTEHIDE_SECRETS_ENVIRONMENT=development

# Windows (Command Prompt)
set BYTEHIDE_SECRETS_TOKEN=your-token-here
set BYTEHIDE_SECRETS_ENVIRONMENT=development

Production Environment

In production, set these variables through your hosting platform:

  • AWS Lambda/EC2: Environment Variables
  • Google Cloud Run: Environment configuration
  • Docker: Environment flags
  • Kubernetes: ConfigMaps or Secrets

Verify Installation

After initializing the SDK, you can verify it's working by accessing a test secret:

Go
package main

import (
    "fmt"
    "log"

    "github.com/bytehide/bytehide-secrets-go/secrets"
)

func main() {
    // Attempt to get a secret
    secret, err := secrets.Get("test")
    if err != nil {
        log.Fatal("Error:", err)
    }
    fmt.Println("Secret retrieved successfully!")
    _ = secret
}

Next Steps

Previous
CI/CD Integration