Inheritance: IHashProvider
コード例 #1
0
 public static string GetHash(this IPackage package, CryptoHashProvider hashProvider)
 {
     using (Stream stream = package.GetStream())
     {
         return(Convert.ToBase64String(hashProvider.CalculateHash(stream)));
     }
 }
コード例 #2
0
 public ExpandedPackageRepository(
     IFileSystem fileSystem,
     CryptoHashProvider hashProvider)
 {
     _fileSystem   = fileSystem;
     _hashProvider = hashProvider;
 }
コード例 #3
0
        public static string GenerateUniqueToken(string caseInsensitiveKey)
        {
            // SHA256 is case sensitive; given that our key is case insensitive, we upper case it
            var pathBytes    = Encoding.UTF8.GetBytes(caseInsensitiveKey.ToUpperInvariant());
            var hashProvider = new CryptoHashProvider();

            return(Convert.ToBase64String(hashProvider.CalculateHash(pathBytes)).ToUpperInvariant());
        }
コード例 #4
0
        /// <summary>
        /// We want to base the lock name off of the full path of the package, however, the Mutex looks for files on disk if a path is given.
        /// Additionally, it also fails if the string is longer than 256 characters. Therefore we obtain a base-64 encoded hash of the path.
        /// </summary>
        /// <seealso cref="http://social.msdn.microsoft.com/forums/en-us/clr/thread/D0B3BF82-4D23-47C8-8706-CC847157AC81"/>
        private static string GenerateUniqueToken(IPackageManager packageManager, string packageId, SemanticVersion version)
        {
            var packagePath = packageManager.FileSystem.GetFullPath(packageManager.PathResolver.GetPackageFileName(packageId, version));
            var pathBytes = Encoding.UTF8.GetBytes(packagePath);
            var hashProvider = new CryptoHashProvider("SHA256");

            return Convert.ToBase64String(hashProvider.CalculateHash(pathBytes)).ToUpperInvariant();
        }
コード例 #5
0
ファイル: EncryptionUtility.cs プロジェクト: Newtopian/nuget
        public static string GenerateUniqueToken(string caseInsensitiveKey)
        {
            // SHA256 is case sensitive; given that our key is case insensitive, we upper case it
            var pathBytes = Encoding.UTF8.GetBytes(caseInsensitiveKey.ToUpperInvariant());
            var hashProvider = new CryptoHashProvider("SHA256");

            return Convert.ToBase64String(hashProvider.CalculateHash(pathBytes)).ToUpperInvariant();
        }