Skip to content

Instantly share code, notes, and snippets.

View marcoonroad's full-sized avatar
🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past

Marco Aurélio da Silva marcoonroad

🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past
View GitHub Profile
@marcoonroad
marcoonroad / powershell_command_urandom.js
Created December 10, 2020 20:50 — forked from kennwhite/powershell_command_urandom.js
Powershell 1-liner to generate random n-byte key from Windows command line
// Windows equivalent to Linux/Mac: echo $(head -c 64 /dev/urandom | base64 | tr -d '\n')
// Get-Random in Windows 10/Server 2016 PowerShell uses a CSPRNG seed by default.
// Prior to PS 5.1, seed was system clock.
// For Win 10/2016+
powershell -command "[Convert]::ToBase64String((1..64|%{[byte](Get-Random -Max 256)}))"
// For Win 8.x/2012
powershell -command "$r=[byte[]]::new(64);$g=[System.Security.Cryptography.RandomNumberGenerator]::Create();$g.GetBytes($r);[Convert]::ToBase64String($r)"
@marcoonroad
marcoonroad / js-crypto-libraries.md
Created April 8, 2019 20:04 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@marcoonroad
marcoonroad / hashcrypt.js
Created November 1, 2018 18:11 — forked from rndme/hashcrypt.js
Symmetric encryption using hash function and key derivation
function hashCrypt(key, plain, hasher, workFactor=1) { // hasher is any sync string-output hash function
var len=plain.length, keyLen = key.length, keyOrig = key,
// calculate derivation count based on deterministic factors from the inputs:
mx = hasher(key).split("").map((a, b)=> a.charCodeAt(0) + b).reduce((a, b)=> a + b, 0) * workFactor;
// derive firstly for some hardness using cpu and ram hungry calculations:
for(let i = 0; i < mx; i++) key = hasher(key.repeat( ((i+len) % ((workFactor || 1) * 4))+1 ));
// expand key to needed length by appending re-hashing (with counters):
@marcoonroad
marcoonroad / Hash Ladders for Shorter Lamport Signatures.md
Created October 30, 2018 14:39 — forked from karlgluck/Hash Ladders for Shorter Lamport Signatures.md
I describe a method for making Lamport signatures take up less space. I haven't seen anyone use hash chains this way before, so I think it's pretty cool.

What's this all about?

Digital cryptography! This is a subject I've been interested in since taking a class with Prof. Fred Schneider back in college. Articles pop up on Hacker News fairly often that pique my interest and this technique is the result of one of them.

Specifically, this is about Lamport signatures. There are many signature algorithms (ECDSA and RSA are the most commonly used) but Lamport signatures are unique because they are formed using a hash function. Many cryptographers believe that this makes them resistant to attacks made possible by quantum computers.

How does a Lamport Signature work?

@marcoonroad
marcoonroad / Makefile
Created October 25, 2018 03:23 — forked from jessevanherk/Makefile
A sample makefile and support files to build a love2d game for multiple platforms from linux
LOVE_BIN=/usr/bin/love
LOVE_DIR=./src/love
DIST_DIR=./src/dist
PATCH_DIR=./src/patch
BUILD_DIR=./build
BIN_DIR=./bin
LOVE_VERSION=0.9.1
GAME_NAME=MySampleGame
PRETTY_NAME=My Sample Game
@marcoonroad
marcoonroad / random.md
Created June 4, 2018 22:12 — 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

CvRDTs are (almost?) as general as they can be

What are you talking about, and why should I care?

Now that we live in the Big Data, Web 3.14159 era, lots of people want to build databases that are too big to fit on a single machine. But there's a problem in the form of the CAP theorem, which states that if your network ever partitions (a machine goes down, or part of the network loses its connection to the rest) then you can keep consistency (all machines return the same answer to

@marcoonroad
marcoonroad / INSTALL.md
Last active August 29, 2015 14:08 — forked from namuol/INSTALL.md

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

function defmulti(keyfn)
if not keyfn then
keyfn = function(...) return ... end
end
local multi = {
_keyfn = keyfn,
_methods = {}
}
setmetatable(multi, {
__call = function(self, ...)
module Fib using: Platform where
open Platform Prelude expose [+, parse, as-string, ~]
open Platform List expose [zip:using:, map:, take:, filter:, sum]
open Platform IO expose [read-line, print]
-- Typing things is currently cumbersome, but the type inference algorithm should catch 90% of this
let (Num a) => String -> a ::
x as-number = x parse