Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sstream>
- #include <napi.h>
- #include "ed25519.h"
- #define SEED_LENGTH 32
- namespace bindings_ed25519
- {
- Napi::Value create_seed(const Napi::CallbackInfo &info)
- {
- Napi::Env env = info.Env();
- if(info.Length() != 0)
- {
- Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
- return env.Null();
- }
- unsigned char seed[SEED_LENGTH];
- int code = ed25519_create_seed(seed);
- if(code != 0)
- {
- Napi::TypeError::New(env, "Failed to create seed").ThrowAsJavaScriptException();
- return env.Null();
- }
- return Napi::Buffer<unsigned char>::Copy(env, seed, SEED_LENGTH);;
- }
- /* ... */
- }
- Napi::Object init(Napi::Env env, Napi::Object exports)
- {
- exports.Set(Napi::String::New(env, "ed25519_create_seed"), Napi::Function::New(env, bindings_ed25519::create_seed));
- return exports;
- }
- NODE_API_MODULE(addon, init)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement