1
- #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER ) || NUGETFORUNITY_CLI )
1
+ #pragma warning disable SA1512 , SA1124 // Single-line comments should not be followed by blank line
2
+ #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD ) || NUGETFORUNITY_CLI )
2
3
using JetBrains . Annotations ;
3
4
#else
4
5
using System . Security . Cryptography ;
5
6
#endif
7
+
8
+ #region No ReShaper
9
+
10
+ // ReSharper disable All
11
+ // needed because 'JetBrains.Annotations.NotNull' and 'System.Diagnostics.CodeAnalysis.NotNull' collide if this file is compiled with a never version of Unity / C#
12
+ using SuppressMessageAttribute = System . Diagnostics . CodeAnalysis . SuppressMessageAttribute ;
13
+
14
+ // ReSharper restore All
15
+
16
+ #endregion
17
+
6
18
using System ;
7
- using System . Diagnostics . CodeAnalysis ;
8
19
using System . Text ;
9
20
using UnityEngine ;
10
21
11
22
namespace NugetForUnity . Configuration
12
23
{
13
24
/// <summary>
14
- /// Helper to encrypt sensitive data so they don't need to be stored in plaintext inside the configuration file.
25
+ /// Helper to encrypt sensitive data so they don't need to be stored in plain-text inside the configuration file.
15
26
/// </summary>
16
27
internal static class ConfigurationEncryptionHelper
17
28
{
18
29
private static readonly byte [ ] EntropyBytes = Encoding . UTF8 . GetBytes ( "NuGet" ) ;
19
30
20
- #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER ) || NUGETFORUNITY_CLI )
31
+ #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD ) || NUGETFORUNITY_CLI )
21
32
22
33
// on .net framework the type lives in 'System.Security' on .net standard it in 'System.Security.Cryptography.ProtectedData'
23
34
[ ItemCanBeNull ]
@@ -44,7 +55,7 @@ public static string EncryptString(string value)
44
55
{
45
56
var decryptedByteArray = Encoding . UTF8 . GetBytes ( value ) ;
46
57
47
- #if ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER ) || NUGETFORUNITY_CLI
58
+ #if ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD ) || NUGETFORUNITY_CLI
48
59
#pragma warning disable CA1416 // Validate platform compatibility
49
60
var encryptedByteArray = ProtectedData . Protect ( decryptedByteArray , EntropyBytes , DataProtectionScope . CurrentUser ) ;
50
61
#pragma warning restore CA1416 // Validate platform compatibility
@@ -86,7 +97,7 @@ public static string DecryptString(string encryptedString)
86
97
{
87
98
var encryptedByteArray = Convert . FromBase64String ( encryptedString ) ;
88
99
89
- #if ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER ) || NUGETFORUNITY_CLI
100
+ #if ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD ) || NUGETFORUNITY_CLI
90
101
#pragma warning disable CA1416 // Validate platform compatibility
91
102
var decryptedByteArray = ProtectedData . Unprotect ( encryptedByteArray , EntropyBytes , DataProtectionScope . CurrentUser ) ;
92
103
#pragma warning restore CA1416 // Validate platform compatibility
@@ -110,7 +121,7 @@ public static string DecryptString(string encryptedString)
110
121
}
111
122
}
112
123
113
- #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER ) || NUGETFORUNITY_CLI )
124
+ #if ! ( ( UNITY_EDITOR_WIN && UNITY_2023_1_OR_NEWER && NET_STANDARD ) || NUGETFORUNITY_CLI )
114
125
[ CanBeNull ]
115
126
private static byte [ ] ProtectOrUnprotectUsingReflection ( string methodName , byte [ ] data )
116
127
{
0 commit comments