[Pkg-javascript-commits] [node-ripemd160] 39/71: readme: update with usage, convert to/from buffers for novices

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:25:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-ripemd160.

commit 796cb40efe17d22c744c500404a1df31398ba9db
Author: JP Richardson <jprichardson at gmail.com>
Date:   Wed Jan 14 06:56:44 2015 -0600

    readme: update with usage, convert to/from buffers for novices
---
 README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 66 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 39f7428..1a50544 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,77 @@
 ripemd160
 =========
 
-JavaScript component to compute the RIPEMD160 hash of strings or bytes.
+JavaScript component to compute the RIPEMD-160 hash of strings or bytes. This hash is commonly used in crypto currencies
+like Bitcoin.
 
+Usage
+-----
 
-Official Documentation
-----------------------
+### Install
 
-http://cryptocoinjs.com/modules/crypto/ripemd160/
+    npm install --save ripemd160
 
 
+### ripemd160(input)
 
-Credits / License
------------------
+`input` should be either a `string`, `Buffer`, or an `Array`. It returns a `Buffer`. 
 
-Most of the code from CryptoJS https://code.google.com/p/crypto-js/
+**example 1**:
 
-Licensed: BSD3
+```js
+var ripemd16 = require('ripemd160')
+
+var data = 'hello'
+var result = ripemd160(data)
+console.log(result.toString('hex'))
+// => 108f07b8382412612c048d07d13f814118445acd
+```
+
+** example 2**:
+
+```js
+var ripemd16 = require('ripemd160')
+
+var data = new Buffer('hello', 'utf8')
+var result = ripemd160(data)
+console.log(result.toString('hex'))
+// => 108f07b8382412612c048d07d13f814118445acd
+```
+
+
+#### converting Buffers
+
+If you're not familiar with the Node.js ecosystem, type `Buffer` is a common way that a developer can pass around
+binary data. `Buffer` also exists in the [Browserify](http://browserify.org/) environment. Converting to and from Buffers is very easy.
+
+##### to buffer
+
+```js
+// from string
+var buf = new Buffer('some string', 'utf8')
+
+// from hex string
+var buf = new Buffer('3f5a4c22', 'hex')
+
+// from array
+var buf = new Buffer([1, 2, 3, 4])
+```
+
+#### from buffer
+
+```js
+// to string
+var str = buf.toString('utf8')
+
+// to hex string
+var hex = buf.toString('hex')
+
+// to array
+var arr = [].slice.call(buf)
+```
+
+
+License
+-------
+
+Licensed: BSD3-Clause

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ripemd160.git



More information about the Pkg-javascript-commits mailing list