@@ -18,6 +18,7 @@ extern "C" {
1818 #include " hefty1.h"
1919 #include " shavite3.h"
2020 #include " cryptonight.h"
21+ #include " x13.h"
2122}
2223
2324using namespace node ;
@@ -422,6 +423,28 @@ Handle<Value> cryptonight(const Arguments& args) {
422423 return scope.Close (buff->handle_ );
423424}
424425
426+ Handle<Value> x13 (const Arguments& args) {
427+ HandleScope scope;
428+
429+ if (args.Length () < 1 )
430+ return except (" You must provide one argument." );
431+
432+ Local<Object> target = args[0 ]->ToObject ();
433+
434+ if (!Buffer::HasInstance (target))
435+ return except (" Argument should be a buffer object." );
436+
437+ char * input = Buffer::Data (target);
438+ char output[32 ];
439+
440+ uint32_t input_len = Buffer::Length (target);
441+
442+ x13_hash (input, output, input_len);
443+
444+ Buffer* buff = Buffer::New (output, 32 );
445+ return scope.Close (buff->handle_ );
446+ }
447+
425448void init (Handle<Object> exports) {
426449 exports->Set (String::NewSymbol (" quark" ), FunctionTemplate::New (quark)->GetFunction ());
427450 exports->Set (String::NewSymbol (" x11" ), FunctionTemplate::New (x11)->GetFunction ());
@@ -439,6 +462,7 @@ void init(Handle<Object> exports) {
439462 exports->Set (String::NewSymbol (" hefty1" ), FunctionTemplate::New (hefty1)->GetFunction ());
440463 exports->Set (String::NewSymbol (" shavite3" ), FunctionTemplate::New (shavite3)->GetFunction ());
441464 exports->Set (String::NewSymbol (" cryptonight" ), FunctionTemplate::New (cryptonight)->GetFunction ());
465+ exports->Set (String::NewSymbol (" x13" ), FunctionTemplate::New (x13)->GetFunction ());
442466}
443467
444468NODE_MODULE (multihashing, init)
0 commit comments