JavaScript component to compute the RIPEMD-160 hash of strings or bytes. This hash is commonly used in crypto currencies like Bitcoin.
npm install --save ripemd160
input
should be either a string
, Buffer
, or an Array
. It returns a Buffer
.
example 1:
var ripemd16 = require('ripemd160')
var data = 'hello'
var result = ripemd160(data)
console.log(result.toString('hex'))
// => 108f07b8382412612c048d07d13f814118445acd
example 2:
var ripemd16 = require('ripemd160')
var data = new Buffer('hello', 'utf8')
var result = ripemd160(data)
console.log(result.toString('hex'))
// => 108f07b8382412612c048d07d13f814118445acd
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 environment. Converting to and from Buffers is very easy.
// 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])
// to string
var str = buf.toString('utf8')
// to hex string
var hex = buf.toString('hex')
// to array
var arr = [].slice.call(buf)
npm install --development
npm run test
Testing in the browser uses the excellent Mochify. Mochify can use either PhantomJS
or an actual browser. You must have Selenium installed if you want to use an actual browser. The easiest way is to
npm install -g start-selenium
and then run start-selenium
.
Then run:
npm run browser-test
Licensed: BSD3-Clause
ripemd160 ========= JavaScript component to compute the RIPEMD-160 hash of strings or bytes. This hash is commonly used in crypto currencies like Bitcoin. Usage ----- ### Install npm install --save ripemd160 ### ripemd160(input) `input` should be either a `string`, `Buffer`, or an `Array`. It returns a `Buffer`. **example 1**: ```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) ``` Testing ------- ### Install dev deps: npm install --development ### Test in Node.js: npm run test ### Test in a Browser: Testing in the browser uses the excellent [Mochify](https://github.com/mantoni/mochify.js). Mochify can use either PhantomJS or an actual browser. You must have Selenium installed if you want to use an actual browser. The easiest way is to `npm install -g start-selenium` and then run `start-selenium`. Then run: npm run browser-test License ------- Licensed: BSD3-Clause
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/ripemd160/README.md | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |