Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add streams support, unroll loops #13

Merged
merged 1 commit into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/

.DS_Store
npm-debug.log
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
sudo: false
os:
- linux
language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
- "io.js"
- "4"
- "5"
env:
matrix:
- TEST_SUITE=unit
matrix:
include:
- node_js: "4"
env: TEST_SUITE=lint
env:
- TEST_SUITE=unit
script: npm run-script $TEST_SUITE
80 changes: 13 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,27 @@
ripemd160
=========
# ripemd160

[![NPM Package](https://img.shields.io/npm/v/ripemd160.svg?style=flat-square)](https://www.npmjs.org/package/ripemd160)
[![Build Status](https://img.shields.io/travis/crypto-browserify/ripemd160.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/ripemd160)
[![Dependency status](https://img.shields.io/david/crypto-browserify/ripemd160.svg?style=flat-square)](https://david-dm.org/crypto-browserify/ripemd160#info=dependencies)

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

JavaScript component to compute the RIPEMD-160 hash of strings or bytes. This hash is commonly used in crypto currencies
like Bitcoin.
Node style `ripemd160` on pure JavaScript.

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
## Example

```js
// to string
var str = buf.toString('utf8')
var RIPEMD160 = require('ripemd160')

// to hex string
var hex = buf.toString('hex')
console.log(new RIPEMD160().update('42').digest('hex'))
// => 0df020ba32aa9b8b904471ff582ce6b579bf8bc8

// to array
var arr = [].slice.call(buf)
var ripemd160stream = new RIPEMD160()
ripemd160stream.end('42')
console.log(ripemd160stream.read().toString('hex'))
// => 0df020ba32aa9b8b904471ff582ce6b579bf8bc8
```

License
-------
## LICENSE

Licensed: BSD3-Clause
MIT
Loading