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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -5
  3. data/jwk-tool.gemspec +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 948f10914152938492f08b0190e45f9b81e03cd2
4
- data.tar.gz: 44a10ff54fb9fb4a3db46149de189e05f8cce714
3
+ metadata.gz: 230b342743bd1ece240fd9f2cf27c925073d17e1
4
+ data.tar.gz: 39914ac78b0791ee64e1d503166424a9b05f3d81
5
5
  SHA512:
6
- metadata.gz: 64e28dcad302984466632af656c92296afc47106b52b138e0946d6501fe13673d7a1d320221bc24764046cee7456d37b54b33d3b88f9962aca1f36c31bb30151
7
- data.tar.gz: f057fe393814b5e303e6adbf449155d9f8d7a18ea5a24cf8bcff2aca7b4725596b9a6b960a3694d4778fdcd8f0b45ab59f06ac80bc48df593723c5810be2e81f
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 'privkey' and public key 'privkey.pub' into the current folder.
13
-
14
- jwk_tool -g -k privkey
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
+ ``
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "jwk-tool"
3
- gem.version = "0.0.2"
3
+ gem.version = "0.0.3"
4
4
 
5
5
  gem.authors = ["Toyokazu Akiyama"]
6
6
  gem.email = ["toyokazu@gmail.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwk-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama