Skip to content

Instantly share code, notes, and snippets.

View cnio's full-sized avatar
📌
V for Vendetta

cnio cnio

📌
V for Vendetta
View GitHub Profile
Verify Github on Galaxy. gid:w7FJkhVbSotdwxy4tjcnuW
@cnio
cnio / delegated-tx.js
Created November 28, 2019 02:57 — forked from libotony/delegated-tx.js
Build delegated tx by thor-devkit.js
const originPriv = Buffer.from('c962bfd916c0f8d4c1866b11a24802815cf58ba981354fad0ac734d0217cfe73', 'hex')
const txOrigin = cry.publicKeyToAddress(cry.secp256k1.derivePublicKey(originPriv))
const delegatorPriv = Buffer.from('dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65', 'hex')
const delegator = cry.publicKeyToAddress(cry.secp256k1.derivePublicKey(delegatorPriv))
const tx = new Transaction({
chainTag: 0x27,
blockRef: '0x002b99c540c4e267',
expiration: 30 * 8640, // Expires after 30 days
@cnio
cnio / delegated-tx.js
Created November 28, 2019 02:57 — forked from libotony/delegated-tx.js
Build delegated tx by thor-devkit.js
const originPriv = Buffer.from('c962bfd916c0f8d4c1866b11a24802815cf58ba981354fad0ac734d0217cfe73', 'hex')
const txOrigin = cry.publicKeyToAddress(cry.secp256k1.derivePublicKey(originPriv))
const delegatorPriv = Buffer.from('dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65', 'hex')
const delegator = cry.publicKeyToAddress(cry.secp256k1.derivePublicKey(delegatorPriv))
const tx = new Transaction({
chainTag: 0x27,
blockRef: '0x002b99c540c4e267',
expiration: 30 * 8640, // Expires after 30 days
@cnio
cnio / random.md
Created May 14, 2019 10:02 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

{"sig":"da70cf9281b0a8c666d296a843b9294cb7120fa204b763a3740872ee16b6c7a7d1574dd46958e4aa7771e7987ca37da76a909ccdef2449a104be0dad8e671e8d0","msghash":"17675f6539f96145194ccb201f1256d99459fa8e4e2423543e78888e84abca8c"}
{"sig":"da70cf9281b0a8c666d296a843b9294cb7120fa204b763a3740872ee16b6c7a7d1574dd46958e4aa7771e7987ca37da76a909ccdef2449a104be0dad8e671e8d0","msghash":"17675f6539f96145194ccb201f1256d99459fa8e4e2423543e78888e84abca8c"}
@cnio
cnio / docker create user in home directory
Created April 21, 2016 07:10
docker create user in home/
# in dockerfile
RUN useradd -ms /bin/bash new_user_name
# in cli
useradd -ms /bin/bash new_user_name