macOS (using Homebrew):
brew tap hashicorp/tap
brew install hashicorp/tap/vaultLinux:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vaultvault server -devThis will output something like:
Root Token: hvs.6j4cuewowBGit65rheNoceI7
Unseal Key: not needed in dev mode
Export the following environment variables:
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='hvs.6j4cuewowBGit65rheNoceI7'
In another terminal, export the variables shown in the output:
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='hvs.6j4cuewowBGit65rheNoceI7' # Use your actual tokenvault statusShould show:
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.x.x
Storage Type inmem
Cluster Name vault-cluster-xxx
Cluster ID xxx
HA Enabled false
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='your-root-token-here'
node vault-encryption.jsnode vault-encryption.js --vault-addr http://127.0.0.1:8200 --vault-token your-tokennode vault-encryption.js --testProblem: Vault server is not running
Solution: Start Vault server with vault server -dev
Problem: Invalid or missing token Solution: Make sure VAULT_TOKEN is set correctly
Problem: Vault is sealed (production mode) Solution: Unseal Vault or use development mode
Problem: Certificate issues with HTTPS Solution: Use development mode with HTTP or configure proper certificates
For production use, you'll need to:
- Initialize and unseal Vault properly
- Configure authentication methods
- Set up proper policies
- Use HTTPS with valid certificates
See HashiCorp's official documentation for production deployment.
# Test encryption functionality
node vault-encryption.js --test
# Generate 100 encrypted records (default)
node vault-encryption.js
# Generate 1000 records to custom file
node vault-encryption.js --records 1000 --output large-dataset.csv
# Use custom Vault configuration
VAULT_ADDR='https://vault.company.com' VAULT_TOKEN='real-token' node vault-encryption.js