parent
0d99d6664b
commit
ed306ed9f1
@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
*~
|
*~
|
||||||
|
node_modules/
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
khash:
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
install:
|
||||||
|
cp ./target/release/libkana_hash.so /usr/lib/libkana_hash.so
|
@ -0,0 +1,22 @@
|
|||||||
|
const ffi = require('ffi');
|
||||||
|
const struct = require('ref-struct');
|
||||||
|
const ref = require('ref');
|
||||||
|
|
||||||
|
|
||||||
|
const libhkana = ffi.Library('libkana_hash', {
|
||||||
|
'_kana_new_salt': ['int', ['pointer', 'long', 'pointer']],
|
||||||
|
'_kana_free_salt': ['int', ['pointer']],
|
||||||
|
'_kana_do': ['int', ['pointer', 'long', 'pointer', 'pointer', 'long']],
|
||||||
|
'_kana_length': ['int', ['pointer', 'long', 'pointer', 'pointer']],
|
||||||
|
});
|
||||||
|
|
||||||
|
const Kana = require('./kana');
|
||||||
|
|
||||||
|
let buffer= ref.alloc('long');
|
||||||
|
let sz = ref.alloc('long');
|
||||||
|
console.log(libhkana._kana_length(buffer, 2, null, sz));
|
||||||
|
console.log(sz.deref());
|
||||||
|
|
||||||
|
let output = new Buffer(sz);
|
||||||
|
console.log(libhkana._kana_do(buffer, 2, null, output, sz));
|
||||||
|
console.log(ref.readCString(output, 0));
|
@ -0,0 +1,10 @@
|
|||||||
|
const ffi = require('ffi');
|
||||||
|
const struct = require('ref-struct');
|
||||||
|
const ref = require('ref');
|
||||||
|
|
||||||
|
const Salt = module.exports.Salt = struct({
|
||||||
|
'size': 'pointer',
|
||||||
|
'body': 'pointer',
|
||||||
|
});
|
||||||
|
const PSalt = module.exports.PSalt = ref.refType(Salt);
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"name": "kana-hash",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"bindings": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||||
|
"requires": {
|
||||||
|
"file-uri-to-path": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "2.6.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||||
|
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ffi": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ffi/-/ffi-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-vkPA9Hf9CVuQ5HeMZykYvrZF2QNJ/iKGLkyDkisBnoOOFeFXZQhUPxBARPBIZMJVulvBI2R+jgofW03gyPpJcQ==",
|
||||||
|
"requires": {
|
||||||
|
"bindings": "~1.2.0",
|
||||||
|
"debug": "2",
|
||||||
|
"nan": "2",
|
||||||
|
"ref": "1",
|
||||||
|
"ref-struct": "1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bindings": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz",
|
||||||
|
"integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"file-uri-to-path": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
},
|
||||||
|
"nan": {
|
||||||
|
"version": "2.14.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
|
||||||
|
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
||||||
|
},
|
||||||
|
"ref": {
|
||||||
|
"version": "1.3.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/ref/-/ref-1.3.5.tgz",
|
||||||
|
"integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==",
|
||||||
|
"requires": {
|
||||||
|
"bindings": "1",
|
||||||
|
"debug": "2",
|
||||||
|
"nan": "2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ref-struct": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ref-struct/-/ref-struct-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=",
|
||||||
|
"requires": {
|
||||||
|
"debug": "2",
|
||||||
|
"ref": "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "kana-hash",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Kana hashes",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"ffi": "^2.3.0",
|
||||||
|
"ref-struct": "^1.1.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue