From 1eea2ecacef4398d0806042ded266ead9db39de8 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 18 Aug 2011 01:21:19 +0200 Subject: Implement Threefish. --- util.rkt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util.rkt') diff --git a/util.rkt b/util.rkt index aa9714d..5f25e2e 100644 --- a/util.rkt +++ b/util.rkt @@ -20,6 +20,7 @@ (provide integer->bytes integer->bytes/size bytes->integer + bytes->integer/le pad-bytes Justification Endianness @@ -58,6 +59,13 @@ (bitwise-ior (arithmetic-shift n 8) byte))) +(define: (bytes->integer/le [b : Bytes]) : Exact-Nonnegative-Integer + (for/fold: ([n : Exact-Nonnegative-Integer 0]) + ([byte : Byte (in-bytes b)] + [i : Integer (in-naturals)]) + (bitwise-ior (arithmetic-shift byte (* i 8)) + n))) + (define: (pad-bytes [b : Bytes] [s : Exact-Nonnegative-Integer] [fill : Byte] -- cgit v1.2.3