-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f154cc
Showing
31 changed files
with
11,966 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build & Test Package | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
linux-node10: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '10.x' | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm install | ||
- run: npm test | ||
|
||
linux-node12: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm install | ||
- run: npm test | ||
|
||
windows-node10: | ||
runs-on: windows-2016 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '10.x' | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm install | ||
- run: npm test | ||
|
||
windows-node12: | ||
runs-on: windows-2016 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Publish Package | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '10.x' | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm install | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.vscode/ | ||
.idea/ | ||
*.iml | ||
node_modules/ | ||
build/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
hasher-phi1 | ||
=========== | ||
|
||
This is a Node module for simple hashing of the phi1 (phi1612) algorithm. | ||
Native code is adapted from [LUX](https://github.com/Lux-core/lux). | ||
|
||
This module has been developed and tested on [Node v10.16.3](https://nodejs.org/) and [Ubuntu 16.04](http://releases.ubuntu.com/16.04/) | ||
|
||
## Install ## | ||
__Install as Dependency in NodeJS Project__ | ||
```bash | ||
# Install from Github git package | ||
|
||
sudo apt-get install build-essential | ||
npm install mintpond/hasher-phi1 --save | ||
``` | ||
-or- | ||
```bash | ||
# Install from Github NPM repository | ||
|
||
sudo apt-get install build-essential | ||
npm config set @mintpond:registry https://npm.pkg.github.com/mintpond | ||
npm config set //npm.pkg.github.com/:_authToken <MY_GITHUB_AUTH_TOKEN> | ||
|
||
npm install @mintpond/[email protected] --save | ||
``` | ||
|
||
__Install & Test__ | ||
```bash | ||
# Install nodejs v10 | ||
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | ||
sudo apt-get install nodejs -y | ||
|
||
# Download hasher-phi1 | ||
git clone https://github.com/MintPond/hasher-phi1 | ||
|
||
# build | ||
cd hasher-phi1 | ||
sudo apt-get install build-essential | ||
npm install | ||
npm test | ||
``` | ||
|
||
## Usage ## | ||
__Hash__ | ||
```js | ||
const phi1 = require('hasher-phi1'); | ||
|
||
/** | ||
* Hash the data in a Buffer and return the result in a new Buffer. | ||
* | ||
* @param input {Buffer} The data to hash. | ||
* @returns {Buffer} | ||
*/ | ||
const result = phi1.phi1612(input); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "hasherphi1", | ||
"sources": [ | ||
"hasherphi1.cc", | ||
"phi1612.c", | ||
"lyra2/lyra2.c", | ||
"lyra2/sponge.c", | ||
"sha3/aes_helper.c", | ||
"sha3/gost_streebog.c", | ||
"sha3/sph_cubehash.c", | ||
"sha3/sph_echo.c", | ||
"sha3/sph_fugue.c", | ||
"sha3/sph_jh.c", | ||
"sha3/sph_skein.c" | ||
], | ||
"include_dirs": [ | ||
"<!(node -e \"require('nan')\")" | ||
], | ||
"cflags_cc": [ | ||
"-std=c++0x" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <node.h> | ||
#include <node_buffer.h> | ||
#include <v8.h> | ||
#include <stdint.h> | ||
#include "nan.h" | ||
|
||
extern "C" { | ||
#include "phi1612.h" | ||
} | ||
|
||
#define THROW_ERROR_EXCEPTION(x) Nan::ThrowError(x) | ||
#define THROW_ERROR_EXCEPTION_WITH_STATUS_CODE(x, y) NanThrowError(x, y) | ||
|
||
using namespace node; | ||
using namespace v8; | ||
|
||
NAN_METHOD(phi1612) { | ||
|
||
if (info.Length() < 1) | ||
return THROW_ERROR_EXCEPTION("You must provide one argument."); | ||
|
||
Local<Object> target = Nan::To<Object>(info[0]).ToLocalChecked(); | ||
|
||
if(!Buffer::HasInstance(target)) | ||
return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); | ||
|
||
char* input = Buffer::Data(target); | ||
char* output = (char*) malloc(sizeof(char) * 32); | ||
|
||
uint32_t input_len = Buffer::Length(target); | ||
|
||
phi1612_hash(input, output, input_len); | ||
|
||
info.GetReturnValue().Set(Nan::NewBuffer(output, 32).ToLocalChecked()); | ||
} | ||
|
||
|
||
NAN_MODULE_INIT(init) { | ||
Nan::Set(target, Nan::New("phi1612").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(phi1612)).ToLocalChecked()); | ||
} | ||
|
||
NODE_MODULE(hasherphi1, init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('bindings')('hasherphi1.node'); |
Oops, something went wrong.