Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert a buffer (of bytes) to a number

56 views
Skip to first unread message

Ron Aaron

unread,
Feb 8, 2016, 3:29:02 AM2/8/16
to
One of our users needed to convert a large buffer of bytes into a number
(e.g. for crypto). Here's the end result:

http://8th-dev.com/forum/index.php/topic,777.0.html

WJ

unread,
Feb 8, 2016, 9:31:46 AM2/8/16
to
Oforth:

: try |buf i|
MemBuffer newSize(80) -> buf
// Fill the buffer with random bytes.
buf size loop: i [buf put(i, 256 rand 1-)]
buf reduce(#[swap 256 * +])
asStringOfBase(16) . ;

> try
973e588beceaed4d4d5e25d939636161acc66f5435c070650a58dd0e8b765fad1a029db2aec5b0ec
09635d7c022fbb7ab91979c82f94603220a53d428aecdef5c6f747b7a39ac7ca5f981288f16c159f
ok

--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html
https://www.youtube.com/watch?v=EEl_1HWFRfo
0 new messages