jwk-tool 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -5
- data/jwk-tool.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 230b342743bd1ece240fd9f2cf27c925073d17e1
|
4
|
+
data.tar.gz: 39914ac78b0791ee64e1d503166424a9b05f3d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af620e617f8847b64dc9d53fec2e7b06ec3d77122e8e6b4de33c483143ac0c21572fd9b6b10924ba188e4a3264cc59bb2e6e96508dc3c7d70203d97fd6f5bde8
|
7
|
+
data.tar.gz: 0810f01b69e43328c971cb78201d81213693e2ff3a1f37be58f1dbcdfaea6bfe8d355946c35a32f1cccfa46e1433d2bced6e64e62f3e7da7707eabbd2640890d
|
data/README.md
CHANGED
@@ -2,14 +2,44 @@
|
|
2
2
|
|
3
3
|
Command line tools for operating JSON Web Key
|
4
4
|
|
5
|
-
|
6
5
|
# Install
|
7
6
|
|
8
7
|
gem install jwk-tool
|
9
8
|
|
10
9
|
# Usage
|
11
10
|
|
12
|
-
The following command generate key pairs, private key '
|
13
|
-
|
14
|
-
jwk_tool -g -k
|
15
|
-
|
11
|
+
The following command generate key pairs, private key 'key' and public key 'key.pub' into the current folder.
|
12
|
+
|
13
|
+
jwk_tool -g -k key
|
14
|
+
jwk_tool --generate --key=key
|
15
|
+
|
16
|
+
To use the keys as JSON Web Key (JSON::JWK) defined in json-jwk, just read files, parse them and then pass to the initialization method.
|
17
|
+
|
18
|
+
An encryption example at sender node using public key.
|
19
|
+
|
20
|
+
``ruby:sender.rb
|
21
|
+
require 'json/jwk'
|
22
|
+
# read public key from file
|
23
|
+
jwk_pub = JSON::JWK.new(JSON.parse(open('hoge.pub').read))
|
24
|
+
# encrypt plain text "hogehogefoofoo"
|
25
|
+
jwe = JSON::JWE.new("hogehogefoofoo")
|
26
|
+
# choose block cipher algorithm
|
27
|
+
jwe.enc = :A128GCM
|
28
|
+
# choose cipher algorithm for encrypting block cipher key (symmetric cipher key)
|
29
|
+
jwe.alg = :RSA1_5
|
30
|
+
# encryption
|
31
|
+
jwe.encrypt!(jwk_pub.to_key)
|
32
|
+
# output the result in JSON format
|
33
|
+
json = jwe.as_json.to_json
|
34
|
+
``
|
35
|
+
|
36
|
+
A decryption example at receiver node using private key.
|
37
|
+
|
38
|
+
``ruby
|
39
|
+
# read private key from file
|
40
|
+
jwk = JSON::JWK.new(JSON.parse(open('hoge').read))
|
41
|
+
# decrypt JSON format cipher data
|
42
|
+
jwe_dec = JSON::JWE.decode_json_serialized(JSON.parse(json), jwk.to_key)
|
43
|
+
# obtain the original plain text
|
44
|
+
jwe_dec.plain_text
|
45
|
+
``
|
data/jwk-tool.gemspec
CHANGED