Skip to content

Commit

Permalink
(chocolatey#836) Initial fix up of new additions
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed Apr 13, 2021
1 parent ac0a2a9 commit 008deb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
// Copyright 2017 - Present Chocolatey Software, LLC
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
// </copyright>
// --

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// --------------------------------------------------------------------------------------------------------------------

namespace ChocolateyGui.Common.Windows.Services
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
// Copyright 2017 - Present Chocolatey Software, LLC
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
// </copyright>
// --
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Text;
using chocolatey;

namespace ChocolateyGui.Common.Windows.Services
Expand All @@ -22,22 +19,18 @@ public class PackageArgumentsService : IPackageArgumentsService

public string Decrypt(string id, string version)
{
var packageFolder = "{0}.{1}";
var packageId = id;
var packageVersion = version;
var chocolateyPath = @"C:\ProgramData\chocolatey\.chocolatey";
var argumentsPath = Path.Combine(chocolateyPath, packageFolder.format_with(id, version));
var argumentsPath = Path.Combine(chocolateyPath, "{0}.{1}".format_with(id, version));
var argumentsFile = Path.Combine(argumentsPath, ".arguments");

// Get the arguments decrypted in here and return them
try
{
if (File.Exists(argumentsFile))
{
string fileName = argumentsFile;
var encryptedBytes = Convert.FromBase64String(File.ReadAllText(fileName));
var encryptedBytes = Convert.FromBase64String(File.ReadAllText(argumentsFile));
var decryptedBytes = ProtectedData.Unprotect(encryptedBytes, EntropyBytes, DataProtectionScope.LocalMachine);
string decryptedChocoArgs = Encoding.UTF8.GetString(decryptedBytes);
var decryptedChocoArgs = Encoding.UTF8.GetString(decryptedBytes);
return decryptedChocoArgs;
}
else
Expand Down

0 comments on commit 008deb4

Please sign in to comment.