Skip to content

Instantly share code, notes, and snippets.

@vquaiato
Created July 17, 2012 14:48
Show Gist options
  • Save vquaiato/3129839 to your computer and use it in GitHub Desktop.
Save vquaiato/3129839 to your computer and use it in GitHub Desktop.
Nuget Install Command Generate Token implementation
//http://nuget.codeplex.com/SourceControl/changeset/view/435b2c2e1ddd#src%2fCommandLine%2fCommands%2fInstallCommand.cs
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment