Skip to content

Instantly share code, notes, and snippets.

@svasva
Last active December 25, 2015 17:39
Show Gist options
  • Select an option

  • Save svasva/7015142 to your computer and use it in GitHub Desktop.

Select an option

Save svasva/7015142 to your computer and use it in GitHub Desktop.
#include <node.h>
#include <v8.h>
#include "scrypt.h"
using namespace v8;
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
String::AsciiValue value(args[0]->ToString());
char* output = (char*) malloc(32);
int n;
for (n=0; n<32; n++) {
output[n] = '\0';
}
::scrypt_1024_1_1_256(*value, output);
return scope.Close(String::New(output));
}
void init(Handle<Object> target) {
target->Set(String::NewSymbol("scrypt"), FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(scrypt, init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment