summaryrefslogtreecommitdiff
path: root/util.rkt
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-08-18 01:21:19 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-08-18 01:21:19 +0200
commit1eea2ecacef4398d0806042ded266ead9db39de8 (patch)
treeed5d5a1e46c4ad0b6521020f6d6c3ef903429231 /util.rkt
parenta040de5c1f8c505e497149b901ed5ccf42288a53 (diff)
Implement Threefish.
Diffstat (limited to 'util.rkt')
-rw-r--r--util.rkt8
1 files changed, 8 insertions, 0 deletions
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]