[Pkg-javascript-commits] [node-keygrip] 23/68: syntax highlighting
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Fri Jun 27 22:13:25 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to branch master
in repository node-keygrip.
commit ce75ac064b79a55ae0a667202814421354adcf49
Author: Jed Schmidt <tr at nslator.jp>
Date: Sun Jan 15 10:21:16 2012 +0900
syntax highlighting
---
README.md | 96 +++++++++++++++++++++++++++++++++------------------------------
1 file changed, 50 insertions(+), 46 deletions(-)
diff --git a/README.md b/README.md
index d72736f..97ce4c1 100644
--- a/README.md
+++ b/README.md
@@ -17,11 +17,13 @@ This creates a new Keygrip based on the provided keylist, an array of secret key
Note that the `new` operator is also optional, so all of the following will work when `Keygrip = require( "keygrip" )`:
- keys = new Keygrip
- keys = new Keygrip([ "SEKRIT2", "SEKRIT1" ])
- keys = Keygrip()
- keys = Keygrip([ "SEKRIT2", "SEKRIT1" ])
- keys = require( "keygrip" )()
+```javascript
+keys = new Keygrip
+keys = new Keygrip([ "SEKRIT2", "SEKRIT1" ])
+keys = Keygrip()
+keys = Keygrip([ "SEKRIT2", "SEKRIT1" ])
+keys = require( "keygrip" )()
+```
The keylist is an array of all valid keys for signing, in descending order of freshness; new keys should be `unshift`ed into the array and old keys should be `pop`ped.
@@ -45,47 +47,49 @@ This uses `index` to return `true` if the digest matches any existing keys, and
## Example
- // ./test.js
- var assert = require( "assert" )
- , Keygrip = require( "keygrip" )
- , keylist, keys, hash, index
-
- // keygrip takes an array of keys, but if none exist,
- // it uses the defaults created during npm installation.
- // (but it'll will warn you)
- console.log( "Ignore this message:" )
- keys = new Keygrip( /* empty list */ )
-
- // .sign returns the hash for the first key
- // all hashes are SHA1 HMACs in url-safe base64
- hash = keys.sign( "bieberschnitzel" )
- assert.ok( /^[\w\-]{27}$/.test( hash ) )
-
- // but we're going to use our list.
- // (note that the 'new' operator is optional)
- keylist = [ "SEKRIT3", "SEKRIT2", "SEKRIT1" ]
- keys = Keygrip( keylist )
- hash = keys.sign( "bieberschnitzel" )
-
- // .index returns the index of the first matching key
- index = keys.index( "bieberschnitzel", hash )
- assert.equal( index, 0 )
-
- // .verify returns the a boolean indicating a matched key
- matched = keys.verify( "bieberschnitzel", hash )
- assert.ok( matched )
-
- index = keys.index( "bieberschnitzel", "o_O" )
- assert.equal( index, -1 )
-
- // rotate a new key in, and an old key out
- keylist.unshift( "SEKRIT4" )
- keylist.pop()
-
- // if index > 0, it's time to re-sign
- index = keys.index( "bieberschnitzel", hash )
- assert.equal( index, 1 )
- hash = keys.sign( "bieberschnitzel" )
+```javascript
+// ./test.js
+var assert = require( "assert" )
+ , Keygrip = require( "keygrip" )
+ , keylist, keys, hash, index
+
+// keygrip takes an array of keys, but if none exist,
+// it uses the defaults created during npm installation.
+// (but it'll will warn you)
+console.log( "Ignore this message:" )
+keys = new Keygrip( /* empty list */ )
+
+// .sign returns the hash for the first key
+// all hashes are SHA1 HMACs in url-safe base64
+hash = keys.sign( "bieberschnitzel" )
+assert.ok( /^[\w\-]{27}$/.test( hash ) )
+
+// but we're going to use our list.
+// (note that the 'new' operator is optional)
+keylist = [ "SEKRIT3", "SEKRIT2", "SEKRIT1" ]
+keys = Keygrip( keylist )
+hash = keys.sign( "bieberschnitzel" )
+
+// .index returns the index of the first matching key
+index = keys.index( "bieberschnitzel", hash )
+assert.equal( index, 0 )
+
+// .verify returns the a boolean indicating a matched key
+matched = keys.verify( "bieberschnitzel", hash )
+assert.ok( matched )
+
+index = keys.index( "bieberschnitzel", "o_O" )
+assert.equal( index, -1 )
+
+// rotate a new key in, and an old key out
+keylist.unshift( "SEKRIT4" )
+keylist.pop()
+
+// if index > 0, it's time to re-sign
+index = keys.index( "bieberschnitzel", hash )
+assert.equal( index, 1 )
+hash = keys.sign( "bieberschnitzel" )
+```
## TODO
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-keygrip.git
More information about the Pkg-javascript-commits
mailing list