<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
To make an erlang integer from crypto:rand_bytes:<br>
<br>
<tt>big_random_int(Bytes) -><br>
B = crypto:rand_bytes(Bytes),<br>
crypto:erlint(<<Bytes:32/unsigned-big-integer,
B/binary>>).<br>
</tt><br>
I'd rather use rand_uniform/2, though.<br>
/Jakob<br>
<br>
<br>
Jakob Cederlund wrote:
<blockquote cite="mid:46B89061.4010801@erix.ericsson.se" type="cite">
<pre wrap="">In crypto you also have rand_uniform/2 which accepts large integers, and
mpint/1 that converts from binary form.
/Jakob
Jim McCoy wrote:
</pre>
<blockquote type="cite">
<pre wrap="">After bouncing through the various bits of doc related to io_lib I
can't quite seem to put together a quick function that will convert an
arbitrary binary to a big int (e.g. I want the integer for
crypto:rand_bytes(40)...)
Any hints?
jim
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<pre wrap=""><!---->
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>