9
與包hashids,我可以從數字散列(編碼和解碼Ÿ)得到的字符串散列,像hashids
var Hashids = require("hashids"),
hashids = new Hashids("this is my salt", 8);
var id = hashids.encode(1);
存在一些類似的包獲取哈希從字符串? (帶編碼/解碼)
與包hashids,我可以從數字散列(編碼和解碼Ÿ)得到的字符串散列,像hashids
var Hashids = require("hashids"),
hashids = new Hashids("this is my salt", 8);
var id = hashids.encode(1);
存在一些類似的包獲取哈希從字符串? (帶編碼/解碼)
var Hashids = require("hashids");
var hashids = new Hashids("this is my salt");
var hex = Buffer('Hello World').toString('hex');
console.log (hex); // '48656c6c6f20576f726c64'
var encoded = hashids.encodeHex(hex);
console.log (encoded); // 'rZ4pPgYxegCarB3eXbg'
var decodedHex = hashids.decodeHex('rZ4pPgYxegCarB3eXbg');
console.log (decodedHex); // '48656c6c6f20576f726c64'
var string = Buffer('48656c6c6f20576f726c64', 'hex').toString('utf8');
console.log (string); // 'Hello World'
Buffer?我在哪裏可以找到它?謝謝! – Eusthace 2017-05-02 00:54:21
https://nodejs.org/api/buffer.html – 2017-06-28 13:34:55
客戶端?瀏覽器... :) – Eusthace 2017-06-28 22:50:07