Skip to content

Commit

Permalink
add lyra2z support
Browse files Browse the repository at this point in the history
  • Loading branch information
devnull-ed committed Jan 21, 2018
1 parent f9d89bb commit 4399870
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions multihashing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,29 @@ NAN_METHOD(fresh) {
info.GetReturnValue().Set(Nan::NewBuffer(output, 32).ToLocalChecked());
}


NAN_METHOD(lyra2z) {

if (info.Length() < 1)
return THROW_ERROR_EXCEPTION("You must provide one argument.");

// Local<Object> target = info[0]->ToObject();
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);


lyra2z_hash(input, output);

info.GetReturnValue().Set(Nan::NewBuffer(output, 32).ToLocalChecked());
}


NAN_MODULE_INIT(init) {
Nan::Set(target, Nan::New("quark").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(quark)).ToLocalChecked());
Nan::Set(target, Nan::New("x11").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(x11)).ToLocalChecked());
Expand All @@ -601,6 +624,8 @@ NAN_MODULE_INIT(init) {
Nan::Set(target, Nan::New("x15").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(x15)).ToLocalChecked());
Nan::Set(target, Nan::New("fresh").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(fresh)).ToLocalChecked());
Nan::Set(target, Nan::New("neoscrypt").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(neoscrypt_hash)).ToLocalChecked());
Nan::Set(target, Nan::New("lyra2z").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(lyra2z)).ToLocalChecked());

}

NODE_MODULE(multihashing, init)

0 comments on commit 4399870

Please sign in to comment.