260222fccac3a4980341918df80fa29c2b4bc3c6
[webi-installers/.git] / keypairs / README.md
1 ---
2 title: keypairs
3 homepage: https://github.com/therootcompany/keypairs
4 tagline: |
5   keypairs: a cross-platform tool for RSA, ECDSA, JWT, JOSE, and general asymmetric encryption
6 ---
7
8 To update or switch versions, run `webi keypairs@stable`.
9
10 ## Cheat Sheet
11
12 > keypairs is like JWT.io, at your fingertips.
13
14 - Generates NIST standard RSA and ECDSA keys
15 - Signatures output as JWT and JWS (JSONE)
16 - Verifies signatures
17
18 ### How to generate JSON Web Keys (JWKs)
19
20 ```bash
21 # keypairs gen -key <key.format> -pub <pub.format>
22 keypairs gen -key key.jwk.json -pub pub.jwk.json
23 ```
24
25 JWK is the default format, for which you can use stdout (key) and stderr (pub)
26
27 ```bash
28 keypairs gen > key.jwk.json 2> pub.jwk.json
29 ```
30
31 ### How to generate PEM (PKCS) keys
32
33 ```bash
34 keypairs gen -key key.pem -pub pub.pem
35 ```
36
37 Or DER
38
39 ```bash
40 keypairs gen -key key.der -pub pub.der
41 ```
42
43 ### How to sign a payload
44
45 ```bash
46 # keypairs sign --exp 1h <priv key> <data or file> > token.jwt 2> sig.jws
47 keypairs sign --exp 1h key.jwk.json '{ "sub": "me@example.com" }' > token.jwt 2> sig.jws
48 ```
49
50 ### How to verify a signature
51
52 ```bash
53 # keypairs sign --exp 1h <pub key> <signed file or data>
54 keypairs sign --exp 1h pub.jwk.json token.jwt
55 ```