Commit e3cfd2e9f91c4e5ce882685477acef259622b53e
update readme to show new api examples
Paul Frazee committed on 11/20/2014, 10:03:07 PMParent: 3a5b82bd19a19d9f6cc51b0cde25b77c7ee08e62
Files changed
README.md | changed |
README.md | ||
---|---|---|
@@ -1,37 +1,52 @@ | ||
1 | 1 | # SSB-Keys |
2 | 2 | |
3 | -A common module for secure-scuttlebutt projects, provides an API to create or load elliptic-curve keypairs. | |
3 | +A common module for secure-scuttlebutt projects, provides an API to create or load elliptic-curve keypairs and to execute related crypto operations. | |
4 | 4 | |
5 | 5 | ```js |
6 | 6 | var ssbkeys = require('ssb-keys') |
7 | 7 | |
8 | 8 | ssbkeys.create(path, function(err, k) { |
9 | 9 | console.log(k) /* => { |
10 | - id: Buffer(...), | |
11 | - public: Buffer(...), | |
12 | - private: Buffer(...) | |
10 | + id: String, | |
11 | + public: String, | |
12 | + private: String | |
13 | 13 | }*/ |
14 | 14 | }) |
15 | 15 | |
16 | 16 | ssbkeys.load(path, function(err, k) { |
17 | 17 | console.log(k) /* => { |
18 | - id: Buffer(...), | |
19 | - public: Buffer(...), | |
20 | - private: Buffer(...) | |
18 | + id: String, | |
19 | + public: String, | |
20 | + private: String | |
21 | 21 | }*/ |
22 | 22 | }) |
23 | 23 | |
24 | 24 | var k = ssbkeys.createSync(path) |
25 | 25 | console.log(k) /* => { |
26 | - id: Buffer(...), | |
27 | - public: Buffer(...), | |
28 | - private: Buffer(...) | |
26 | + id: String, | |
27 | + public: String, | |
28 | + private: String | |
29 | 29 | }*/ |
30 | 30 | |
31 | 31 | var k = ssbkeys.loadSync(path) |
32 | 32 | console.log(k) /* => { |
33 | - id: Buffer(...), | |
34 | - public: Buffer(...), | |
35 | - private: Buffer(...) | |
33 | + id: String, | |
34 | + public: String, | |
35 | + private: String | |
36 | 36 | }*/ |
37 | + | |
38 | +var k = ssbkeys.generate() | |
39 | +console.log(k) /* => { | |
40 | + id: String, | |
41 | + public: String, | |
42 | + private: String | |
43 | +}*/ | |
44 | + | |
45 | +var hash = ssbkeys.hash(new Buffer('deadbeef', 'hex')) | |
46 | +ssbkeys.isHash(hash) // => true | |
47 | + | |
48 | +var sig = ssbkeys.sign(k, hash) | |
49 | +ssbkeys.verify(k.public, sig, hash) | |
50 | + | |
51 | +ssbkeys.hmac(new Buffer('deadbeef', 'hex'), k.private) // => String | |
37 | 52 | ``` |
Built with git-ssb-web