-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Vault implementation to use System.Security.Cryptography.Prote…
…ctedData
- Loading branch information
1 parent
a31e2a5
commit 696474f
Showing
3 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/ScriptRunner/ScriptRunner.GUI/ViewModels/EncryptionHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace ScriptRunner.GUI.ViewModels; | ||
|
||
public static class EncryptionHelper | ||
{ | ||
private static byte[] EntropyKey = Encoding.ASCII.GetBytes("80CD0C6D-74D3-4E6D-9E4F-ECA485E69FC7"); | ||
|
||
public static string Encrypt(string value) | ||
{ | ||
byte[] data = Encoding.ASCII.GetBytes(value); | ||
string protectedData = Convert.ToBase64String(ProtectedData.Protect(data, EntropyKey, DataProtectionScope.CurrentUser)); | ||
return protectedData; | ||
} | ||
|
||
public static string Decrypt(string value) | ||
{ | ||
byte[] protectedData = Convert.FromBase64String(value); | ||
string data = Encoding.ASCII.GetString(ProtectedData.Unprotect(protectedData, EntropyKey, DataProtectionScope.CurrentUser)); | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters