Exemplo n.º 1
0
 /// <summary>Generates an <see cref="Uuid"/> applying a <see cref="MD5"/> hash on the data.</summary>
 public static Uuid GenerateWithMD5(byte[] data)
 {
     Guard.NotNull(data, nameof(data));
     using (var md5 = MD5.Create())
     {
         var hash = md5.ComputeHash(data);
         UuidExtensions.SetVersion(hash, UuidVersion.MD5);
         return(new Guid(hash));
     }
 }
Exemplo n.º 2
0
 /// <summary>Generates an <see cref="Uuid"/> applying a <see cref="SHA1"/> hash on the data.</summary>
 public static Uuid GenerateWithSHA1(byte[] data)
 {
     Guard.NotNull(data, nameof(data));
     using (var sha1 = SHA1.Create())
     {
         var bytes = sha1.ComputeHash(data);
         var hash  = new byte[16];
         Array.Copy(bytes, hash, 16);
         UuidExtensions.SetVersion(hash, UuidVersion.SHA1);
         return(new Guid(hash));
     }
 }