Skip to content

Instantly share code, notes, and snippets.

@paniq
Created April 6, 2019 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/bbe6610d4e61b527eef45c866c3825d6 to your computer and use it in GitHub Desktop.
Save paniq/bbe6610d4e61b527eef45c866c3825d6 to your computer and use it in GitHub Desktop.
using import Array
let C =
import-c "lib.c"
""""int printf (const char *fmt, ...);
'()
let SerialArray = (GrowingArray hash)
let salt = (hash "a bit of salt")
run-stage;
fn print-serial (i x)
x := x as u64
block1 := x & 0xffff:u64
block2 := x >> 16:u64 & 0xffff:u64
block3 := x >> 32:u64 & 0xffff:u64
block4 := x >> 48:u64 & 0xffff:u64
C.printf "%4i: %04llX-%04llX-%04llX-%04llX\n\n" i
block1
block2
block3
block4
fn print-serials (last N)
local serials : SerialArray
fold (last = last) for i in (range N)
let newval =
hash salt last
'append serials newval
newval
'sort serials
inline (key)
key as u64
for i entry in (enumerate serials)
print-serial i entry
print-serials (hash "seed string") 16
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment