Converting uint[] slice to string for the purpose of hashing?
cym13 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 23 04:49:03 PDT 2015
On Thursday, 23 July 2015 at 11:15:46 UTC, Enjoys Math wrote:
> 1. Is the best way to hash a uint[] slice
>
> 2. How do you do it?
IIRC, std.digest functions take ubyte[] as input, so to hash a
uint[] I would do the following:
void main(string[] args)
{
import std.conv;
import std.digest.md;
int[] a = [1, 2, 3, 4, 5];
auto md5 = new MD5Digest();
md5.put(a.to!(ubyte[]));
auto hash = md5.finish();
writeln(hash);
}
More information about the Digitalmars-d-learn
mailing list