This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate the private and public keys | |
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key | |
# Extract the public key and remove the EC prefix 0x04 | |
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub | |
# Extract the private key and remove the leading zero byte | |
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv | |
# Generate the hash and take the address part |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.shuffle = function(){ | |
var a = this.split(""), | |
n = a.length; | |
for( var i = n - 1; i > 0; i-- ){ | |
var j = Math.floor(Math.random() * (i + 1)); | |
var tmp = a[i]; | |
a[i] = a[j]; | |
a[j] = tmp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require( 'crypto' ); | |
module.exports = { | |
UUIDv4(){ | |
let random_num = crypto.randomBytes(16); | |
random_num[6] = (random_num[6] & 0x0f) | 0x40; | |
random_num[8] = (random_num[8] & 0x3f) | 0x80; | |
return [ | |
random_num.slice(0, 4).toString('hex'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Project: beson | |
* File: fnv1a.js | |
* Author: JCloudYu | |
* Create Date: Sep. 03, 2018 | |
*/ | |
(()=>{ | |
"use strict"; | |
// See http://www.isthe.com/chongo/tech/comp/fnv/#FNV-param for the definition of these parameters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{ | |
"use strict"; | |
module.exports = ()=>{ | |
let resolve, reject; | |
let promise = new Promise((rs, rj)=>{resolve=rs; reject=rj;}); | |
promise.trigger = {resolve, reject}; | |
return promise; | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{ | |
"use strict"; | |
module.exports = async_loop; | |
/** | |
* Provide asynchronous version of for / while loop controlling logic. | |
* This function mimic following logic using setTimeout mechanism. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Author: JCloudYu | |
* Create: 2018/09/15 | |
**/ | |
((exports)=>{ | |
"use strict"; | |
const _previous = exports.EventEmitter; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{ | |
"use strict"; | |
const __FORMAT_CHECK = /^[0123456789ABCDEFGHIJKLMNOPQRSTUV]+$/; | |
const __CHAR_MAP = '0123456789ABCDEFGHIJKLMNOPQRSTUV'.split(''); | |
function __BASE32_ENCODE(inputData, map=null) { | |
if ( !Buffer.isBuffer(inputData) ) { | |
inputData = Buffer.from(inputData); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ISC License | |
Copyright (c) 2018, JCloudYu | |
Permission to use, copy, modify, and/or distribute this software for any | |
purpose with or without fee is hereby granted, provided that the above | |
copyright notice and this permission notice appear in all copies. | |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ISC License | |
* | |
* Copyright (c) 2020, J. Cloud Yu | |
* | |
* Permission to use, copy, modify, and/or distribute this software for any | |
* purpose with or without fee is hereby granted, provided that the above | |
* copyright notice and this permission notice appear in all copies. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
OlderNewer