Solutions
API

API

The PwExchange API is a simple RESTful API that allows you to share passwords with your friends or colleagues in a secure way.

Usage

Installation

git clone https://github.com/secnex/pwexchange-api.git pwexchange
cd pwexchange
 
# Build the tool
docker build -t pwexchange:local .
 
SERVER_SECRET=$(openssl rand -hex 32)
AUTH_TOKEN=$(openssl rand -hex 32)
 
# Run the tool
docker run -p 3030:8080 -e SERVER_SECRET=$SERVER_SECRET -e AUTH_TOKEN=$AUTH_TOKEN pwexchange:local

API

Create a new secret

curl -X POST http://localhost:3030/api/store/encrypt -d '{"password": "my-secret"}' -H "Authorization : Bearer $AUTH_TOKEN"

Response:

{
    "id": "00000000-0000-0000-0000-000000000000",
    "secret": "encryption-key"
}

Decrypt a secret

curl -X POST http://localhost:3030/api/store/decrypt?id=00000000-0000-0000-0000-000000000000 -d '{"secret": "encryption-key"}' -H "Authorization : Bearer $AUTH_TOKEN"

Response:

{
    "password": "my-secret"
}

List all secrets

curl -X GET http://localhost:3030/api/store -H "Authorization : Bearer $AUTH_TOKEN"

Response:

[
    {
        "id": "00000000-0000-0000-0000-000000000000",
        "secret": "encrypted-secret-with-key"
    },
    {
        "id": "00000000-0000-0000-0000-000000000001",
        "secret": "encrypted-secret-with-key"
    }
]