jwesecret is a lightweight Go server and CLI for storing and retrieving secrets (e.g., WiFi passwords, API keys) using asymmetric encryption via JWE (JSON Web Encryption). Secrets can optionally be wrapped in a signed JWT, allowing for identity-carrying, tamper-proof payloads.
- 💂 Secure: RSA-OAEP + AES-GCM encryption
- 🔏 Optional JWT wrapping (
?jwt=trueor--jwt) - 🧪 Includes unit tests for roundtrip encryption and JWT verification
- 🐳 Dockerized with persistent key support
- 🛠 Dual mode: HTTP server or CLI
- 🔒 RSA-2048 and EC-P256 key generation and persistence
- 🔐 JWE encryption (AES-GCM + RSA-OAEP or ECDH-ES)
- 🧾 Optional JWT wrapping (
?jwt=trueor--jwt) - 🌐 HTTP server with
/encryptand/decryptendpoints - 🛠 CLI interface with
--mode encrypt|decrypt - 🐳 Docker support
By default, jwesecret uses EC (Elliptic Curve) cryptography. You can also choose RSA via CLI flag or environment variable.
- EC (default): ECDH-ES (JWE) + ES256 (JWT)
- RSA: RSA-OAEP-256 (JWE) + RS256 (JWT)
go run jwesecret.go --mode encrypt --input "secret" --keytype rsaexport JWE_KEY_TYPE=rsa
go run jwesecret.go --mode encrypt --input "secret"Or in Docker:
docker run -e JWE_KEY_TYPE=rsa -p 8888:8888 jwesecret[User Secret]
|
v
[Encrypt with Public Key (RSA/EC)]
|
v
[AES-GCM Encrypted Payload (JWE)]
|
v
[Store or Transmit Securely]
|
v
[Recipient Decrypts with Private Key (RSA/EC)]
|
v
[Original Secret Recovered]
[User Secret]
|
v
[Encrypt with Public Key → JWE]
|
v
[Wrap JWE into JWT Claim (e.g., "data")]
|
v
[Sign JWT with Private Key]
|
v
[JWT Token Sent / Stored]
|
v
[Recipient Verifies JWT Signature (Public Key)]
|
v
[Extract "data" claim → Encrypted Payload]
|
v
[Decrypt JWE using Private Key]
|
v
[Recover Original Secret]
+-----------------+
| jwesecret App |
+--------+--------+
|
+-------------+-------------+
| |
[CLI Mode] [HTTP Server Mode]
| |
+--------v---------+ +-------v--------+
| Flags: | | Endpoints: |
| --mode encrypt | | /encrypt |
| --input SECRET | | /decrypt |
| [--jwt] | | ?jwt=true |
+--------+---------+ +-------+--------+
| |
+---------v----------+ +----------v---------+
| Output to stdout | | Response to client|
+--------------------+ +--------------------+
go run jwesecret.goOr via Docker:
docker build -t jwesecret .
docker run -p 8888:8888 jwesecretcurl -X POST http://localhost:8888/encrypt -d 'super-secret'With JWT wrapping:
curl -X POST 'http://localhost:8888/encrypt?jwt=true' -d 'super-secret'curl -X POST http://localhost:8888/decrypt -d '<JWE>'With JWT:
curl -X POST http://localhost:8888/decrypt?jwt=true -d '<JWT>'go run jwesecret.go --mode encrypt --input "my secret"With JWT wrapping:
go run jwesecret.go --mode encrypt --input "my secret" --jwtgo run jwesecret.go --mode decrypt --input "<jwe-or-jwt>" --jwt| Key | Value |
|---|---|
| Author | Nick Conolly |
| Version | 0.0.3 |
| GitHub | @iamgaru |
| License | MIT |