secure trip

hash-command-arbitrary
Avril 4 years ago
parent 8cf6b2f473
commit fad14d0a30
Signed by untrusted user: flanchan
GPG Key ID: 284488987C31F630

1
.gitignore vendored

@ -8,6 +8,7 @@ www/favicon.ico
stage/
homepage/
*~
*.node
*.pid

@ -24,7 +24,7 @@
"formidable": "1.0.17",
"hashloli": "git+ssh://public@flanchan.moe:hashloli.git",
"jsoncompress": "^0.1.3",
"kana-hash": "file:../home/flandre/work/libkhash/node",
"kana-hash": "file:../kana-hash/node",
"minimist": "1.2.0",
"nan": "^2.14.0",
"recaptcha2": "^1.3.2",

@ -23,7 +23,7 @@ var _ = require('../lib/underscore'),
render = require('./render'),
request = require('request'),
STATE = require('./state'),
tripcode = {hash:function(a,b){return new khash.Kana(0, this.salt).once(a);}, setSalt:function(a){if(a) this.salt = new khash.Salt(a); else this.salt = khash.Salt.Default; return this.salt;}}, //require('./../tripcode/tripcode'),
tripcode = require('../tripcode').make(),//{hash:function(a,b){return new khash.Kana(0, this.salt).once(a);}, setSalt:function(a){if(a) this.salt = new khash.Salt(a); else this.salt = khash.Salt.Default; return this.salt;}}, //require('./../tripcode/tripcode'),
urlParse = require('url').parse,
web = require('./web'),
winston = require('winston');

@ -0,0 +1,46 @@
const hash = require('kana-hash');
function Tripcode(algo, salt)
{
this.algo = algo || hash.Kana.ALGO_DEFAULT;
this.salt = salt ? new hash.Kana(salt) : hash.Salt.Default;
}
Tripcode.Algorithm = {
Default: hash.Kana.ALGO_DEFAULT,
Crc32: hash.Kana.ALGO_CRC32,
Crc64: hash.Kana.ALGO_CRC64,
Sha256: hash.Kana.ALGO_SHA256,
Sha256T: hash.Kana.ALGO_SHA256_TRUNCATED,
};
Tripcode.make = (algo, salt) => {
return new Tripcode(algo,salt);b
};
Object.freeze(Tripcode.Algorithm);
const TC = Tripcode.prototype;
TC.hash = function(a, b, c) {
console.log("what are these?:");
if (a) {
// Insecure
return "!" +new hash.Kana(this.algo, hash.Salt.Default).once(a);
} else if (b) {
// Secure
return "!!" +new hash.Kana(this.algo, this.salt).once(b);
}
};
TC.setSalt = function(salt) {
if (salt)
this.salt = new hash.Salt(salt);
else if(salt === true)
this.salt = hash.Salt.Default;
else if (salt === false)
this.salt = hash.Salt.None;
return this.salt;
};
module.exports = Tripcode;
Loading…
Cancel
Save