Beispiel #1
0
 public static string ToHashString(this string str, HashAlgorithm algorithm)
 {
     if (str == null)
     {
         return(null);
     }
     return(ToString(algorithm.ComputeHash(Encoding.GetBytes(str))));
 }
Beispiel #2
0
 public static string ToHashString(this Stream inputStream, HashAlgorithm algorithm)
 {
     if (inputStream == null)
     {
         return(null);
     }
     return(ToString(algorithm.ComputeHash(inputStream)));
 }
Beispiel #3
0
 public static string ToHashString(this byte[] buffer, int offset, int count, HashAlgorithm algorithm)
 {
     if (buffer == null)
     {
         return(null);
     }
     return(ToString(algorithm.ComputeHash(buffer, offset, count)));
 }
Beispiel #4
0
 public static string ToHashString(this byte[] buffer, HashAlgorithm algorithm)
 {
     if (buffer == null)
     {
         return(null);
     }
     return(ToString(algorithm.ComputeHash(buffer)));
 }
        public static string HashWith(this string input, HashAlgorithmProvider algorithm)
        {
            CryptographicHash objHash = algorithm.CreateHash();
            IBuffer buffMsg1 = CryptographicBuffer.ConvertStringToBinary(input, BinaryStringEncoding.Utf16BE);
            objHash.Append(buffMsg1);
            IBuffer buffHash1 = objHash.GetValueAndReset();

            return CryptographicBuffer.EncodeToBase64String(buffHash1);
        }
Beispiel #6
0
        public static string HashWith(this string input, HashAlgorithmProvider algorithm)
        {
            throw new NotImplementedException("got to figure out how to do this");

             //           var data = Encoding.UTF8.GetBytes(input);
             //           var hash = algorithm.HashData(CryptographicBuffer.ConvertStringToBinary(data));
             //           //var hash = algorithm.CreateHash()(data);
             //           return Convert.ToBase64String(CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, hash));
        }
Beispiel #7
0
        private byte[] GetHash(byte[] pbEntropy)
        {
            byte[] pbNewData;

#if KeePassUWP
            Wscc.HashAlgorithmProvider hashAlgo = Wscc.HashAlgorithmProvider.OpenAlgorithm(Wscc.HashAlgorithmNames.Sha512);
            pbNewData = hashAlgo.HashData(pbEntropy.AsBuffer()).ToArray();
#else
#if KeePassLibSD
            using (SHA256Managed shaNew = new SHA256Managed())
#else
            using (SHA512Managed shaNew = new SHA512Managed())
#endif
            {
                pbNewData = shaNew.ComputeHash(pbEntropy);
            }
#endif

            return(pbNewData);
        }
 public UAPHashAlgorithmProvider(HashAlgorithmProvider provider)
 {
     this.provider = provider;
 }
Beispiel #9
0
 public HashMessageDigest(string algorithm)
 {
     _provider = HashAlgorithmProvider.OpenAlgorithm(algorithm);
     Init();
 }
 private void Init(string algorithmName)
 {
     _hasher = HashAlgorithmProvider.OpenAlgorithm(algorithmName);
     Clear();
 }
Beispiel #11
0
 static Hash()
 {
     SHA256 = HashAlgorithmProvider.OpenAlgorithm("SHA256");
     SHA384 = HashAlgorithmProvider.OpenAlgorithm("SHA384");
     SHA512 = HashAlgorithmProvider.OpenAlgorithm("SHA512");
 }
        /// <summary>
        /// Static Constructor
        /// </summary>
        static ImageCache()
        {
            // Default cache duration is a day
            CacheDuration = TimeSpan.FromHours(24);

            // Cache Handlers
            CacheHandlers.Add(new ApplicationUriCacheHandler());
            CacheHandlers.Add(new HttpUriCacheHandler());
            CacheHandlers.Add(new StorageFileCacheHandler());
            CacheHandlers.Add(new StreamCacheHandler());

            // Algorithm Provider
            AlgorithmProvider = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1);
        }