Example #1
0
        public async Task <HashValue> ComputeHashAsync(Stream data, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var hash = await xx.ComputeHashAsync(data, cancellationToken);

            return(new HashValue(hash.Hash));
        }
Example #2
0
        public static async Task <string> ComputeHash(this string text)
        {
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text)))
            {
                var value = await HashFunction.ComputeHashAsync(stream);

                return(value.AsBase64String());
            }
        }
        public static async Task <string> ComputeHash(this object obj)
        {
            var serialized = JsonConvert.SerializeObject(obj);

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(serialized)))
            {
                var value = await HashFunction.ComputeHashAsync(stream);

                return(value.AsBase64String());
            }
        }
Example #4
0
 public async Task <byte[]> ComputeHashAsync(Stream stream)
 {
     return((await algorithm.ComputeHashAsync(stream).ConfigureAwait(false)).Hash);
 }