Skip to content

Commit

Permalink
always unse rflection on unity as it only works in some special cases (
Browse files Browse the repository at this point in the history
  • Loading branch information
JoC0de authored Oct 29, 2023
1 parent 5a1e296 commit 9aeae7d
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma warning disable SA1512,SA1124 // Single-line comments should not be followed by blank line
#if !((UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD) || NUGETFORUNITY_CLI)
#if !NUGETFORUNITY_CLI
using JetBrains.Annotations;
#else
using System.Security.Cryptography;
Expand Down Expand Up @@ -28,7 +28,7 @@ internal static class ConfigurationEncryptionHelper
{
private static readonly byte[] EntropyBytes = Encoding.UTF8.GetBytes("NuGet");

#if !((UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD) || NUGETFORUNITY_CLI)
#if !NUGETFORUNITY_CLI

// on .net framework the type lives in 'System.Security' on .net standard it in 'System.Security.Cryptography.ProtectedData'
[ItemCanBeNull]
Expand All @@ -55,7 +55,7 @@ public static string EncryptString(string value)
{
var decryptedByteArray = Encoding.UTF8.GetBytes(value);

#if (UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD) || NUGETFORUNITY_CLI
#if NUGETFORUNITY_CLI
#pragma warning disable CA1416 // Validate platform compatibility
var encryptedByteArray = ProtectedData.Protect(decryptedByteArray, EntropyBytes, DataProtectionScope.CurrentUser);
#pragma warning restore CA1416 // Validate platform compatibility
Expand Down Expand Up @@ -97,7 +97,7 @@ public static string DecryptString(string encryptedString)
{
var encryptedByteArray = Convert.FromBase64String(encryptedString);

#if (UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD) || NUGETFORUNITY_CLI
#if NUGETFORUNITY_CLI
#pragma warning disable CA1416 // Validate platform compatibility
var decryptedByteArray = ProtectedData.Unprotect(encryptedByteArray, EntropyBytes, DataProtectionScope.CurrentUser);
#pragma warning restore CA1416 // Validate platform compatibility
Expand All @@ -121,7 +121,7 @@ public static string DecryptString(string encryptedString)
}
}

#if !((UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD) || NUGETFORUNITY_CLI)
#if !NUGETFORUNITY_CLI
[CanBeNull]
private static byte[] ProtectOrUnprotectUsingReflection(string methodName, byte[] data)
{
Expand Down

0 comments on commit 9aeae7d

Please sign in to comment.