Migrate the Strata.Base.Internal to C#

This commit is contained in:
Jorge Burgos 2025-01-31 16:16:50 -05:00
parent 60d5186581
commit b10f40dd28
20 changed files with 2493 additions and 8 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Strata.Base.Internal\Strata.Base.Internal.vbproj" />
<ProjectReference Include="..\Strata.Base.Internal\Strata.Base.Internal.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<AssemblyName>Strata.Base.Internal.Tests</AssemblyName>
<RootNamespace>Strata.Base.Internal.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Strata.Base.Internal\Strata.Base.Internal.vbproj" />
</ItemGroup>
</Project>

View File

@ -1,8 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.0.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.vbproj", "{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.csproj", "{6948FC8A-673B-0B97-11F1-2FBDDF225514}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal.Tests", "Strata.Base.Internal.Tests\Strata.Base.Internal.Tests.csproj", "{11111111-1111-1111-1111-111111111111}"
EndProject
@ -12,10 +12,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.Build.0 = Release|Any CPU
{6948FC8A-673B-0B97-11F1-2FBDDF225514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6948FC8A-673B-0B97-11F1-2FBDDF225514}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6948FC8A-673B-0B97-11F1-2FBDDF225514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6948FC8A-673B-0B97-11F1-2FBDDF225514}.Release|Any CPU.Build.0 = Release|Any CPU
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11111111-1111-1111-1111-111111111111}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.0.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.vbproj", "{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal.Tests", "Strata.Base.Internal.Tests\Strata.Base.Internal.Tests.csproj", "{11111111-1111-1111-1111-111111111111}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.Build.0 = Release|Any CPU
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11111111-1111-1111-1111-111111111111}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11111111-1111-1111-1111-111111111111}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5C6D0F1F-E91E-4F6A-9E9F-B3E2DA7F2B4D}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,13 @@
using System;
namespace Strata.Base.Internal.Encryptors
{
public interface IPasswordEncryptionMethod
{
string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt);
}
}

View File

@ -0,0 +1,56 @@
using System;
using System.Configuration;
using Microsoft.VisualBasic;
using Strata.Configuration.Client.Models.Jazz;
namespace Strata.Base.Internal.Encryptors
{
public class UberEncryptionMethod : IPasswordEncryptionMethod
{
public UberEncryptionMethod()
{
}
#region Methods
public static string GetUberMonet(string anOrgPin)
{
return GetUberMonet(DateTime.Today, anOrgPin, ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UberMonetKey)]);
}
private static string GetUberMonet(DateTime aDate, string anOrgPIN, string aKey)
{
var ha = new EncryptionUtils.Hasher(EncryptionUtils.Hasher.Provider.SHA256);
string lsHashBefore;
string lsResult;
lsHashBefore = Strings.Format(aDate, "dd-MM-yyyy") + "-" + anOrgPIN + "-" + aKey;
var d = new EncryptionUtils.Data(lsHashBefore);
var dResult = ha.Calculate(d);
lsResult = Strings.Left(dResult.Hex, 6);
ha = null;
return lsResult;
}
#endregion
#region IPasswordEncryptionMethod
public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt)
{
return GetUberMonet(anOrgPin);
}
#endregion
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Configuration;
using System.Security.Cryptography;
using System.Text;
using Strata.Configuration.Client.Models.Jazz;
namespace Strata.Base.Internal.Encryptors
{
public class UserGUIDEncryptionMethod : IPasswordEncryptionMethod
{
#region Declarations
private const int NUMBER_ITERATIONS = 100000;
#endregion
#region Methods
public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt)
{
string salt = aUserGUID.ToString() + ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UserGuidEncryptionKey)];
string result = GetHashedValue(aNewPassword, salt);
for (int i = 1; i <= NUMBER_ITERATIONS; i++)
result = GetHashedValue(result);
return result;
}
private static string GetHashedValue(string aValue)
{
// Create an instance of the sha encrypter
using (HashAlgorithm hasher = SHA256.Create())
{
return Convert.ToBase64String(hasher.ComputeHash(Encoding.UTF8.GetBytes(aValue)));
}
}
private static string GetHashedValue(string aValue, string aSalt)
{
return GetHashedValue(aValue + aSalt);
}
#endregion
}
}

View File

@ -0,0 +1,65 @@
using System;
using System.Configuration;
using System.Security.Cryptography;
using System.Text;
using Strata.Configuration.Client.Models.Jazz;
namespace Strata.Base.Internal.Encryptors
{
public class UserSaltEncryptionMethod : IPasswordEncryptionMethod
{
#region Declarations
private const int NUMBER_ITERATIONS = 100000;
#endregion
#region Methods
public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt)
{
if (username is null)
{
throw new ArgumentNullException(nameof(username));
}
if (anOrgPin is null)
{
throw new ArgumentNullException(nameof(anOrgPin));
}
if (aNewPassword is null)
{
throw new ArgumentNullException(nameof(aNewPassword));
}
if (aSalt is null)
{
throw new ArgumentNullException(nameof(aSalt));
}
// Get encryption key from config, throw if not found
string encryptionKey = ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UserSaltEncryptionKey)];
if (string.IsNullOrEmpty(encryptionKey))
{
throw new ConfigurationErrorsException("UserSaltEncryptionKey not found in configuration");
}
// Combine salt with encryption key
string saltAndPepper = aSalt + encryptionKey;
// Use UTF8 encoding to properly handle Unicode characters
using (var deriveBytes = new Rfc2898DeriveBytes(aNewPassword, Encoding.UTF8.GetBytes(saltAndPepper), NUMBER_ITERATIONS, HashAlgorithmName.SHA256))
{
byte[] password = deriveBytes.GetBytes(24);
return Convert.ToBase64String(password);
}
}
#endregion
}
}

View File

@ -0,0 +1,11 @@

namespace Strata.Base.Internal
{
internal class InternalConstants
{
// WARNING: This should always match the value in Strata.Base.Constants.XConstants.APPLICATION_VERSION
public const string APPLICATION_VERSION = "2025.11";
}
}

View File

@ -0,0 +1,11 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

View File

@ -0,0 +1,36 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
// Review the values of the assembly attributes
[assembly: AssemblyTitle("Strata.Biz.Internal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("Strata Decision Technology, LLC")]
[assembly: AssemblyProduct("Strata.Biz.Internal")]
[assembly: AssemblyCopyright("© 2006-2012 Strata Decision Technology, LLC")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("dfd98904-a580-4549-90ea-95c9a5504029")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// <Assembly: AssemblyVersion(Strata.Base.Constants.XConstants.APPLICATION_VERSION)>
[assembly: AssemblyVersion(Strata.Base.Internal.InternalConstants.APPLICATION_VERSION)]
[assembly: AssemblyFileVersion(Strata.Base.Internal.InternalConstants.APPLICATION_VERSION)]

View File

@ -0,0 +1,468 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using Microsoft.VisualBasic;
/* TODO ERROR: Skipped IfDirectiveTrivia
#If TARGET = "module" AndAlso _MYTYPE = "" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYTYPE="Empty"
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYTYPE = "WindowsForms" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYFORMS = True
#Const _MYWEBSERVICES = True
#Const _MYUSERTYPE = "Windows"
#Const _MYCOMPUTERTYPE = "Windows"
#Const _MYAPPLICATIONTYPE = "WindowsForms"
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "WindowsFormsWithCustomSubMain" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYFORMS = True
#Const _MYWEBSERVICES = True
#Const _MYUSERTYPE = "Windows"
#Const _MYCOMPUTERTYPE = "Windows"
#Const _MYAPPLICATIONTYPE = "Console"
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "Windows" OrElse _MYTYPE = "" Then
*/
/* TODO ERROR: Skipped DefineDirectiveTrivia
#Const _MYWEBSERVICES = True
*//* TODO ERROR: Skipped DefineDirectiveTrivia
#Const _MYUSERTYPE = "Windows"
*//* TODO ERROR: Skipped DefineDirectiveTrivia
#Const _MYCOMPUTERTYPE = "Windows"
*//* TODO ERROR: Skipped DefineDirectiveTrivia
#Const _MYAPPLICATIONTYPE = "Windows"
*/
/* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "Console" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYWEBSERVICES = True
#Const _MYUSERTYPE = "Windows"
#Const _MYCOMPUTERTYPE = "Windows"
#Const _MYAPPLICATIONTYPE = "Console"
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "Web" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYFORMS = False
#Const _MYWEBSERVICES = False
#Const _MYUSERTYPE = "Web"
#Const _MYCOMPUTERTYPE = "Web"
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "WebControl" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYFORMS = False
#Const _MYWEBSERVICES = True
#Const _MYUSERTYPE = "Web"
#Const _MYCOMPUTERTYPE = "Web"
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE = "Custom" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYTYPE <> "Empty" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const _MYTYPE = "Empty"
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYTYPE <> "Empty" Then
*/
namespace Strata.Base.Internal.My
{
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYAPPLICATIONTYPE = "WindowsForms" OrElse _MYAPPLICATIONTYPE = "Windows" OrElse _MYAPPLICATIONTYPE = "Console" Then
*/
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYAPPLICATIONTYPE = "WindowsForms" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
Inherits Global.Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
#If TARGET = "winexe" Then
<Global.System.STAThread(), Global.System.Diagnostics.DebuggerHidden(), Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Shared Sub Main(ByVal Args As String())
Try
Global.System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(MyApplication.UseCompatibleTextRendering())
Finally
End Try
My.Application.Run(Args)
End Sub
#End If
*//* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYAPPLICATIONTYPE = "Windows" Then
*/
internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ApplicationBase
{
/* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYAPPLICATIONTYPE = "Console" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
Inherits Global.Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If '_MYAPPLICATIONTYPE = "WindowsForms"
*/
}
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If '#If _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Windows" or _MYAPPLICATIONTYPE = "Console"
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYCOMPUTERTYPE <> "" Then
*/
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYCOMPUTERTYPE = "Windows" Then
*/
internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer
{
/* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYCOMPUTERTYPE = "Web" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
Inherits Global.Microsoft.VisualBasic.Devices.ServerComputer
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
[DebuggerHidden()]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public MyComputer() : base()
{
}
}
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
[HideModuleName()]
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
internal static class MyProject
{
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYCOMPUTERTYPE <> "" Then
*/
[System.ComponentModel.Design.HelpKeyword("My.Computer")]
internal static MyComputer Computer
{
[DebuggerHidden()]
get
{
return m_ComputerObjectProvider.GetInstance;
}
}
private readonly static ThreadSafeObjectProvider<MyComputer> m_ComputerObjectProvider = new ThreadSafeObjectProvider<MyComputer>();
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYAPPLICATIONTYPE = "Windows" Or _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Console" Then
*/
[System.ComponentModel.Design.HelpKeyword("My.Application")]
internal static MyApplication Application
{
[DebuggerHidden()]
get
{
return m_AppObjectProvider.GetInstance;
}
}
private readonly static ThreadSafeObjectProvider<MyApplication> m_AppObjectProvider = new ThreadSafeObjectProvider<MyApplication>();
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYUSERTYPE = "Windows" Then
*/
[System.ComponentModel.Design.HelpKeyword("My.User")]
internal static Microsoft.VisualBasic.ApplicationServices.User User
{
[DebuggerHidden()]
get
{
return m_UserObjectProvider.GetInstance;
}
}
private readonly static ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.User> m_UserObjectProvider = new ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.User>();
/* TODO ERROR: Skipped ElifDirectiveTrivia
#ElseIf _MYUSERTYPE = "Web" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
<Global.System.ComponentModel.Design.HelpKeyword("My.User")> _
Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.WebUser
<Global.System.Diagnostics.DebuggerHidden()> _
Get
Return m_UserObjectProvider.GetInstance()
End Get
End Property
Private ReadOnly m_UserObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.WebUser)
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYFORMS = True Then
*//* TODO ERROR: Skipped DisabledTextTrivia
#Const STARTUP_MY_FORM_FACTORY = "My.MyProject.Forms"
<Global.System.ComponentModel.Design.HelpKeyword("My.Forms")> _
Friend ReadOnly Property Forms() As MyForms
<Global.System.Diagnostics.DebuggerHidden()> _
Get
Return m_MyFormsObjectProvider.GetInstance()
End Get
End Property
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Never)> _
<Global.Microsoft.VisualBasic.MyGroupCollection("System.Windows.Forms.Form", "Create__Instance__", "Dispose__Instance__", "My.MyProject.Forms")> _
Friend NotInheritable Class MyForms
<Global.System.Diagnostics.DebuggerHidden()> _
Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Forms.Form})(ByVal Instance As T) As T
If Instance Is Nothing OrElse Instance.IsDisposed Then
If m_FormBeingCreated IsNot Nothing Then
If m_FormBeingCreated.ContainsKey(GetType(T)) = True Then
Throw New Global.System.InvalidOperationException(Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate"))
End If
Else
m_FormBeingCreated = New Global.System.Collections.Hashtable()
End If
m_FormBeingCreated.Add(GetType(T), Nothing)
Try
Return New T()
Catch ex As Global.System.Reflection.TargetInvocationException When ex.InnerException IsNot Nothing
Dim BetterMessage As String = Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message)
Throw New Global.System.InvalidOperationException(BetterMessage, ex.InnerException)
Finally
m_FormBeingCreated.Remove(GetType(T))
End Try
Else
Return Instance
End If
End Function
<Global.System.Diagnostics.DebuggerHidden()> _
Private Sub Dispose__Instance__(Of T As Global.System.Windows.Forms.Form)(ByRef instance As T)
instance.Dispose()
instance = Nothing
End Sub
<Global.System.Diagnostics.DebuggerHidden()> _
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Never)> _
Public Sub New()
MyBase.New()
End Sub
<Global.System.ThreadStatic()> Private Shared m_FormBeingCreated As Global.System.Collections.Hashtable
<Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function Equals(ByVal o As Object) As Boolean
Return MyBase.Equals(o)
End Function
<Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function GetHashCode() As Integer
Return MyBase.GetHashCode
End Function
<Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> _
Friend Overloads Function [GetType]() As Global.System.Type
Return GetType(MyForms)
End Function
<Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function ToString() As String
Return MyBase.ToString
End Function
End Class
Private m_MyFormsObjectProvider As New ThreadSafeObjectProvider(Of MyForms)
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYWEBSERVICES = True Then
*/
[System.ComponentModel.Design.HelpKeyword("My.WebServices")]
internal static MyWebServices WebServices
{
[DebuggerHidden()]
get
{
return m_MyWebServicesObjectProvider.GetInstance;
}
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")]
internal sealed class MyWebServices
{
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[DebuggerHidden()]
public override bool Equals(object o)
{
return base.Equals(o);
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[DebuggerHidden()]
public override int GetHashCode()
{
return base.GetHashCode();
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[DebuggerHidden()]
internal new Type GetType()
{
return typeof(MyWebServices);
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[DebuggerHidden()]
public override string ToString()
{
return base.ToString();
}
[DebuggerHidden()]
private static T Create__Instance__<T>(T instance) where T : new()
{
if (instance is null)
{
return new T();
}
else
{
return instance;
}
}
[DebuggerHidden()]
private void Dispose__Instance__<T>(ref T instance)
{
instance = default;
}
[DebuggerHidden()]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public MyWebServices() : base()
{
}
}
private readonly static ThreadSafeObjectProvider<MyWebServices> m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider<MyWebServices>();
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MYTYPE = "Web" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
<Global.System.ComponentModel.Design.HelpKeyword("My.Request")> _
Friend ReadOnly Property Request() As Global.System.Web.HttpRequest
<Global.System.Diagnostics.DebuggerHidden()> _
Get
Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current
If CurrentContext IsNot Nothing Then
Return CurrentContext.Request
End If
Return Nothing
End Get
End Property
<Global.System.ComponentModel.Design.HelpKeyword("My.Response")> _
Friend ReadOnly Property Response() As Global.System.Web.HttpResponse
<Global.System.Diagnostics.DebuggerHidden()> _
Get
Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current
If CurrentContext IsNot Nothing Then
Return CurrentContext.Response
End If
Return Nothing
End Get
End Property
<Global.System.ComponentModel.Design.HelpKeyword("My.Application.Log")> _
Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.AspLog
<Global.System.Diagnostics.DebuggerHidden()> _
Get
Return m_LogObjectProvider.GetInstance()
End Get
End Property
Private ReadOnly m_LogObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.AspLog)
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If '_MYTYPE="Web"
*/
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.InteropServices.ComVisible(false)]
internal sealed class ThreadSafeObjectProvider<T> where T : new()
{
internal T GetInstance
{
/* TODO ERROR: Skipped IfDirectiveTrivia
#If TARGET = "library" Then
*/
[DebuggerHidden()]
get
{
var Value = m_Context.Value;
if (Value is null)
{
Value = new T();
m_Context.Value = Value;
}
return Value;
}
/* TODO ERROR: Skipped ElseDirectiveTrivia
#Else
*//* TODO ERROR: Skipped DisabledTextTrivia
<Global.System.Diagnostics.DebuggerHidden()> _
Get
If m_ThreadStaticValue Is Nothing Then m_ThreadStaticValue = New T
Return m_ThreadStaticValue
End Get
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
}
[DebuggerHidden()]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public ThreadSafeObjectProvider() : base()
{
}
/* TODO ERROR: Skipped IfDirectiveTrivia
#If TARGET = "library" Then
*/
private readonly Microsoft.VisualBasic.MyServices.Internal.ContextValue<T> m_Context = new Microsoft.VisualBasic.MyServices.Internal.ContextValue<T>();
/* TODO ERROR: Skipped ElseDirectiveTrivia
#Else
*//* TODO ERROR: Skipped DisabledTextTrivia
<Global.System.Runtime.CompilerServices.CompilerGenerated(), Global.System.ThreadStatic()> Private Shared m_ThreadStaticValue As T
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
}
}
}
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/

View File

@ -0,0 +1,241 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using Microsoft.VisualBasic;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See Compiler::LoadXmlSolutionExtension
namespace Strata.Base.Internal.My
{
[Embedded()]
[DebuggerNonUserCode()]
[System.Runtime.CompilerServices.CompilerGenerated()]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
internal sealed class InternalXmlHelper
{
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
private InternalXmlHelper()
{
}
public static string get_Value(IEnumerable<XElement> source)
{
foreach (XElement item in source)
return item.Value;
return null;
}
public static void set_Value(IEnumerable<XElement> source, string value)
{
foreach (XElement item in source)
{
item.Value = value;
break;
}
}
public static string get_AttributeValue(IEnumerable<XElement> source, XName name)
{
foreach (XElement item in source)
return (string)item.Attribute(name);
return null;
}
public static void set_AttributeValue(IEnumerable<XElement> source, XName name, string value)
{
foreach (XElement item in source)
{
item.SetAttributeValue(name, value);
break;
}
}
public static string get_AttributeValue(XElement source, XName name)
{
return (string)source.Attribute(name);
}
public static void set_AttributeValue(XElement source, XName name, string value)
{
source.SetAttributeValue(name, value);
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static XAttribute CreateAttribute(XName name, object value)
{
if (value is null)
{
return null;
}
return new XAttribute(name, value);
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns)
{
var a = new XAttribute(name, ns.NamespaceName);
a.AddAnnotation(ns);
return a;
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, object obj)
{
if (obj is not null)
{
XElement elem = obj as XElement;
if (elem is not null)
{
return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem);
}
else
{
IEnumerable elems = obj as IEnumerable;
if (elems is not null)
{
return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems);
}
}
}
return obj;
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, IEnumerable obj)
{
if (obj is not null)
{
IEnumerable<XElement> elems = obj as IEnumerable<XElement>;
if (elems is not null)
{
return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement);
}
else
{
return obj.Cast<object>().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject);
}
}
return obj;
}
[DebuggerNonUserCode()]
[System.Runtime.CompilerServices.CompilerGenerated()]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
private sealed class RemoveNamespaceAttributesClosure
{
private readonly string[] m_inScopePrefixes;
private readonly XNamespace[] m_inScopeNs;
private readonly List<XAttribute> m_attributes;
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes)
{
m_inScopePrefixes = inScopePrefixes;
m_inScopeNs = inScopeNs;
m_attributes = attributes;
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
internal XElement ProcessXElement(XElement elem)
{
return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem);
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
internal object ProcessObject(object obj)
{
XElement elem = obj as XElement;
if (elem is not null)
{
return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem);
}
else
{
return obj;
}
}
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, XElement e)
{
if (e is not null)
{
var a = e.FirstAttribute;
while (a is not null)
{
var nextA = a.NextAttribute;
if (a.IsNamespaceDeclaration)
{
var ns = a.Annotation<XNamespace>();
string prefix = a.Name.LocalName;
if (ns is not null)
{
if (inScopePrefixes is not null && inScopeNs is not null)
{
int lastIndex = inScopePrefixes.Length - 1;
for (int i = 0, loopTo = lastIndex; i <= loopTo; i++)
{
string currentInScopePrefix = inScopePrefixes[i];
var currentInScopeNs = inScopeNs[i];
if (prefix.Equals(currentInScopePrefix))
{
if (ns == currentInScopeNs)
{
// prefix and namespace match. Remove the unneeded ns attribute
a.Remove();
}
// prefix is in scope but refers to something else. Leave the ns attribute.
a = null;
break;
}
}
}
if (a is not null)
{
// Prefix is not in scope
// Now check whether it's going to be in scope because it is in the attributes list
if (attributes is not null)
{
int lastIndex = attributes.Count - 1;
for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++)
{
var currentA = attributes[i];
string currentInScopePrefix = currentA.Name.LocalName;
var currentInScopeNs = currentA.Annotation<XNamespace>();
if (currentInScopeNs is not null)
{
if (prefix.Equals(currentInScopePrefix))
{
if (ns == currentInScopeNs)
{
// prefix and namespace match. Remove the unneeded ns attribute
a.Remove();
}
// prefix is in scope but refers to something else. Leave the ns attribute.
a = null;
break;
}
}
}
}
if (a is not null)
{
// Prefix is definitely not in scope
a.Remove();
// namespace is not defined either. Add this attributes list
attributes.Add(a);
}
}
}
}
a = nextA;
}
}
return e;
}
}
}

View File

@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Microsoft.VisualBasic
{
[Embedded()]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.CompilerServices.CompilerGenerated()]
internal sealed class Embedded : Attribute
{
}
}

View File

@ -0,0 +1,70 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
using System.Diagnostics;
using Microsoft.VisualBasic;
namespace Strata.Base.Internal.My.Resources
{
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode()]
[System.Runtime.CompilerServices.CompilerGenerated()]
[HideModuleName()]
internal static class Resources
{
private static System.Resources.ResourceManager resourceMan;
private static System.Globalization.CultureInfo resourceCulture;
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
internal static System.Resources.ResourceManager ResourceManager
{
get
{
if (ReferenceEquals(resourceMan, null))
{
var temp = new System.Resources.ResourceManager("Strata.Base.Internal.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
internal static System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,100 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
using System.Diagnostics;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
namespace Strata.Base.Internal.My
{
[System.Runtime.CompilerServices.CompilerGenerated()]
[System.CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
internal sealed partial class MySettings : System.Configuration.ApplicationSettingsBase
{
private static MySettings defaultInstance = (MySettings)Synchronized(new MySettings());
#region My.Settings Auto-Save Functionality
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MyType = "WindowsForms" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
#endregion
public static MySettings Default
{
get
{
/* TODO ERROR: Skipped IfDirectiveTrivia
#If _MyType = "WindowsForms" Then
*//* TODO ERROR: Skipped DisabledTextTrivia
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
*//* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
return defaultInstance;
}
}
[System.Configuration.ApplicationScopedSetting()]
[DebuggerNonUserCode()]
[System.Configuration.DefaultSettingValue("Development")]
public string Environment
{
get
{
return Conversions.ToString(this["Environment"]);
}
}
}
}
namespace Strata.Base.Internal.My
{
[HideModuleName()]
[DebuggerNonUserCode()]
[System.Runtime.CompilerServices.CompilerGenerated()]
internal static class MySettingsProperty
{
[System.ComponentModel.Design.HelpKeyword("My.Settings")]
internal static MySettings Settings
{
get
{
return MySettings.Default;
}
}
}
}

View File

@ -0,0 +1,819 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Strata.Base.Internal.EncryptionUtils
{
#region Hash
/// <summary>
/// Hash functions are fundamental to modern cryptography. These functions map binary
/// strings of an arbitrary length to small binary strings of a fixed length, known as
/// hash values. A cryptographic hash function has the property that it is computationally
/// infeasible to find two distinct inputs that hash to the same value. Hash functions
/// are commonly used with digital signatures and for data integrity.
/// </summary>
public class Hasher
{
/// <summary>
/// Type of hash; some are security oriented, others are fast and simple
/// </summary>
internal enum Provider
{
/// <summary>
/// Secure Hashing Algorithm provider, SHA-2 variant, 256-bit
/// </summary>
SHA256,
/// <summary>
/// Secure Hashing Algorithm provider, SHA-2 variant, 384-bit
/// </summary>
SHA384,
/// <summary>
/// Secure Hashing Algorithm provider, SHA-2 variant, 512-bit
/// </summary>
SHA512
}
private HashAlgorithm _Hash;
private Data _HashValue = new Data();
internal Hasher()
{
}
/// <summary>
/// Instantiate a new hash of the specified type
/// </summary>
internal Hasher(Provider p)
{
switch (p)
{
case Provider.SHA256:
{
_Hash = SHA256.Create();
break;
}
case Provider.SHA384:
{
_Hash = SHA384.Create();
break;
}
case Provider.SHA512:
{
_Hash = SHA512.Create();
break;
}
default:
{
_Hash = SHA256.Create(); // Default to SHA256 for unknown providers
break;
}
}
}
/// <summary>
/// Returns the previously calculated hash
/// </summary>
internal Data Value
{
get
{
return _HashValue;
}
}
/// <summary>
/// Calculates hash on a stream of arbitrary length
/// </summary>
internal Data Calculate(ref Stream s)
{
_HashValue.Bytes = _Hash.ComputeHash(s);
return _HashValue;
}
/// <summary>
/// Calculates hash for fixed length <see cref="Data"/>
/// </summary>
internal Data Calculate(Data d)
{
return CalculatePrivate(d.Bytes);
}
/// <summary>
/// Calculates hash for a string with a prefixed salt value.
/// A "salt" is random data prefixed to every hashed value to prevent
/// common dictionary attacks.
/// </summary>
internal Data Calculate(Data d, Data salt)
{
var nb = new byte[(d.Bytes.Length + salt.Bytes.Length)];
salt.Bytes.CopyTo(nb, 0);
d.Bytes.CopyTo(nb, salt.Bytes.Length);
return CalculatePrivate(nb);
}
/// <summary>
/// Calculates hash for an array of bytes
/// </summary>
private Data CalculatePrivate(byte[] b)
{
_HashValue.Bytes = _Hash.ComputeHash(b);
return _HashValue;
}
}
#endregion
#region Symmetric
/// <summary>
/// Symmetric encryption uses a single key to encrypt and decrypt.
/// Both parties (encryptor and decryptor) must share the same secret key.
/// </summary>
internal class SymmetricEncryptor
{
private const string _DefaultIntializationVector = "%1Az=-@qT";
private const int _BufferSize = 2048;
internal enum Provider
{
/// <summary>
/// Advanced Encryption Standard (AES) provider
/// </summary>
AES
}
private Data _data;
private Data _key;
private Data _iv;
private SymmetricAlgorithm _crypto;
private byte[] _EncryptedBytes;
private bool _UseDefaultInitializationVector;
private SymmetricEncryptor()
{
}
/// <summary>
/// Instantiates a new symmetric encryption object using the specified provider.
/// </summary>
internal SymmetricEncryptor(Provider provider, bool useDefaultInitializationVector = true)
{
_crypto = Aes.Create(); // Always use AES as it's the most secure option
// -- make sure key and IV are always set, no matter what
Key = RandomKey();
if (useDefaultInitializationVector)
{
IntializationVector = new Data(_DefaultIntializationVector);
}
else
{
IntializationVector = RandomInitializationVector();
}
}
/// <summary>
/// Key size in bytes. We use the default key size for any given provider; if you
/// want to force a specific key size, set this property
/// </summary>
internal int KeySizeBytes
{
get
{
return _crypto.KeySize / 8;
}
set
{
_crypto.KeySize = value * 8;
_key.MaxBytes = value;
}
}
/// <summary>
/// Key size in bits. We use the default key size for any given provider; if you
/// want to force a specific key size, set this property
/// </summary>
internal int KeySizeBits
{
get
{
return _crypto.KeySize;
}
set
{
_crypto.KeySize = value;
_key.MaxBits = value;
}
}
/// <summary>
/// The key used to encrypt/decrypt data
/// </summary>
internal Data Key
{
get
{
return _key;
}
set
{
_key = value;
_key.MaxBytes = _crypto.LegalKeySizes[0].MaxSize / 8;
_key.MinBytes = _crypto.LegalKeySizes[0].MinSize / 8;
_key.StepBytes = _crypto.LegalKeySizes[0].SkipSize / 8;
}
}
/// <summary>
/// Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using
/// the value derived from the previous block; the first data block has no previous data block
/// to use, so it needs an InitializationVector to feed the first block
/// </summary>
internal Data IntializationVector
{
get
{
return _iv;
}
set
{
_iv = value;
_iv.MaxBytes = _crypto.BlockSize / 8;
_iv.MinBytes = _crypto.BlockSize / 8;
}
}
/// <summary>
/// generates a random Initialization Vector, if one was not provided
/// </summary>
internal Data RandomInitializationVector()
{
_crypto.GenerateIV();
var d = new Data(_crypto.IV);
return d;
}
/// <summary>
/// generates a random Key, if one was not provided
/// </summary>
internal Data RandomKey()
{
_crypto.GenerateKey();
var d = new Data(_crypto.Key);
return d;
}
/// <summary>
/// Ensures that _crypto object has valid Key and IV
/// prior to any attempt to encrypt/decrypt anything
/// </summary>
private void ValidateKeyAndIv(bool isEncrypting)
{
if (_key.IsEmpty)
{
if (isEncrypting)
{
_key = RandomKey();
}
else
{
throw new CryptographicException("No key was provided for the decryption operation!");
}
}
if (_iv.IsEmpty)
{
if (isEncrypting)
{
_iv = RandomInitializationVector();
}
else
{
throw new CryptographicException("No initialization vector was provided for the decryption operation!");
}
}
try
{
_crypto.Key = _key.Bytes;
_crypto.IV = _iv.Bytes;
}
catch (CryptographicException ex)
{
throw new CryptographicException("Invalid key or initialization vector.", ex);
}
}
/// <summary>
/// Encrypts the specified Data using provided key
/// </summary>
internal Data Encrypt(Data d, Data key)
{
Key = key;
return Encrypt(d);
}
/// <summary>
/// Encrypts the specified Data using preset key and preset initialization vector
/// </summary>
internal Data Encrypt(Data d)
{
var ms = new MemoryStream();
ValidateKeyAndIv(true);
var cs = new CryptoStream(ms, _crypto.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(d.Bytes, 0, d.Bytes.Length);
cs.Close();
ms.Close();
return new Data(ms.ToArray());
}
/// <summary>
/// Encrypts the stream to memory using provided key and provided initialization vector
/// </summary>
internal Data Encrypt(Stream s, Data key, Data iv)
{
IntializationVector = iv;
Key = key;
return Encrypt(s);
}
/// <summary>
/// Encrypts the stream to memory using specified key
/// </summary>
internal Data Encrypt(Stream s, Data key)
{
Key = key;
return Encrypt(s);
}
/// <summary>
/// Encrypts the specified stream to memory using preset key and preset initialization vector
/// </summary>
internal Data Encrypt(Stream s)
{
var ms = new MemoryStream();
var b = new byte[2049];
int i;
ValidateKeyAndIv(true);
var cs = new CryptoStream(ms, _crypto.CreateEncryptor(), CryptoStreamMode.Write);
i = s.Read(b, 0, _BufferSize);
while (i > 0)
{
cs.Write(b, 0, i);
i = s.Read(b, 0, _BufferSize);
}
cs.Close();
ms.Close();
return new Data(ms.ToArray());
}
/// <summary>
/// Decrypts the specified data using provided key and preset initialization vector
/// </summary>
internal Data Decrypt(Data encryptedData, Data key)
{
Key = key;
return Decrypt(encryptedData);
}
/// <summary>
/// Decrypts the specified stream using provided key and preset initialization vector
/// </summary>
internal Data Decrypt(Stream encryptedStream, Data key)
{
Key = key;
return Decrypt(encryptedStream);
}
/// <summary>
/// Decrypts the specified stream using preset key and preset initialization vector
/// </summary>
internal Data Decrypt(Stream encryptedStream)
{
var ms = new MemoryStream();
var b = new byte[2049];
ValidateKeyAndIv(false);
var cs = new CryptoStream(encryptedStream, _crypto.CreateDecryptor(), CryptoStreamMode.Read);
int i;
i = cs.Read(b, 0, _BufferSize);
while (i > 0)
{
ms.Write(b, 0, i);
i = cs.Read(b, 0, _BufferSize);
}
cs.Close();
ms.Close();
return new Data(ms.ToArray());
}
/// <summary>
/// Decrypts the specified data using preset key and preset initialization vector
/// </summary>
internal Data Decrypt(Data encryptedData)
{
using (var ms = new MemoryStream(encryptedData.Bytes, 0, encryptedData.Bytes.Length))
{
ValidateKeyAndIv(false);
using (var cs = new CryptoStream(ms, _crypto.CreateDecryptor(), CryptoStreamMode.Read))
{
using (var outputMs = new MemoryStream())
{
try
{
cs.CopyTo(outputMs);
return new Data(outputMs.ToArray());
}
catch (CryptographicException ex)
{
throw new CryptographicException("Unable to decrypt data. The provided key may be invalid.", ex);
}
}
}
}
}
}
#endregion
#region Data
/// <summary>
/// represents Hex, Byte, Base64, or String data to encrypt/decrypt;
/// use the .Text property to set/get a string representation
/// use the .Hex property to set/get a string-based Hexadecimal representation
/// </summary>
internal class Data
{
private byte[] _b = null;
private int _MaxBytes = 0;
private int _MinBytes = 0;
private int _StepBytes = 0;
/// <summary>
/// Determines the default text encoding for this Data instance
/// </summary>
private Encoding _encoding = Encoding.UTF8;
/// <summary>
/// Creates new, empty encryption data
/// </summary>
internal Data()
{
}
/// <summary>
/// Creates new encryption data with the specified byte array
/// </summary>
internal Data(byte[] b)
{
_b = b;
}
/// <summary>
/// Creates new encryption data with the specified string;
/// will be converted to byte array using UTF8 encoding
/// </summary>
internal Data(string s)
{
if (s is null)
{
throw new ArgumentNullException(nameof(s));
}
Text = s;
}
/// <summary>
/// Creates new encryption data using the specified string and the
/// specified encoding to convert the string to a byte array.
/// </summary>
internal Data(string s, Encoding encoding)
{
if (s is null)
{
throw new ArgumentNullException(nameof(s));
}
if (encoding is null)
{
throw new ArgumentNullException(nameof(encoding));
}
_encoding = encoding;
Text = s;
}
/// <summary>
/// returns true if no data is present
/// </summary>
internal bool IsEmpty
{
get
{
if (_b is null)
{
return true;
}
if (_b.Length == 0)
{
return true;
}
return false;
}
}
/// <summary>
/// allowed step interval, in bytes, for this data; if 0, no limit
/// </summary>
internal int StepBytes
{
get
{
return _StepBytes;
}
set
{
_StepBytes = value;
}
}
/// <summary>
/// allowed step interval, in bits, for this data; if 0, no limit
/// </summary>
internal int StepBits
{
get
{
return _StepBytes * 8;
}
set
{
_StepBytes = value / 8;
}
}
/// <summary>
/// minimum number of bytes allowed for this data; if 0, no limit
/// </summary>
internal int MinBytes
{
get
{
return _MinBytes;
}
set
{
_MinBytes = value;
}
}
/// <summary>
/// minimum number of bits allowed for this data; if 0, no limit
/// </summary>
internal int MinBits
{
get
{
return _MinBytes * 8;
}
set
{
_MinBytes = value / 8;
}
}
/// <summary>
/// maximum number of bytes allowed for this data; if 0, no limit
/// </summary>
internal int MaxBytes
{
get
{
return _MaxBytes;
}
set
{
_MaxBytes = value;
}
}
/// <summary>
/// maximum number of bits allowed for this data; if 0, no limit
/// </summary>
internal int MaxBits
{
get
{
return _MaxBytes * 8;
}
set
{
_MaxBytes = value / 8;
}
}
/// <summary>
/// Returns the byte representation of the data;
/// This will be padded to MinBytes and trimmed to MaxBytes as necessary!
/// </summary>
internal byte[] Bytes
{
get
{
if (_b is null)
{
return Array.Empty<byte>();
}
if (_MaxBytes > 0 && _b.Length > _MaxBytes)
{
var b = new byte[_MaxBytes];
Array.Copy(_b, b, b.Length);
_b = b;
}
if (_MinBytes > 0 && _b.Length < _MinBytes)
{
var b = new byte[_MinBytes];
Array.Copy(_b, b, _b.Length);
_b = b;
}
return _b;
}
set
{
_b = value;
}
}
/// <summary>
/// Sets or returns text representation of bytes using UTF8 encoding
/// </summary>
internal string Text
{
get
{
if (_b is null || _b.Length == 0)
{
return string.Empty;
}
try
{
return _encoding.GetString(_b);
}
catch (Exception ex)
{
// If there's an encoding error, try to salvage what we can
int i = Array.IndexOf(_b, (byte)0);
if (i >= 0)
{
return _encoding.GetString(_b, 0, i);
}
throw;
}
}
set
{
if (value is null)
{
_b = Array.Empty<byte>();
}
else
{
_b = _encoding.GetBytes(value);
}
}
}
/// <summary>
/// Sets or returns Hex string representation of this data
/// </summary>
internal string Hex
{
get
{
return Utils.ToHex(_b);
}
set
{
_b = Utils.FromHex(value);
}
}
/// <summary>
/// Sets or returns Base64 string representation of this data
/// </summary>
internal string Base64
{
get
{
return Utils.ToBase64(_b);
}
set
{
_b = Utils.FromBase64(value);
}
}
}
#endregion
#region Utils
/// <summary>
/// Friend class for shared utility methods used by multiple Encryption classes
/// </summary>
internal class Utils
{
/// <summary>
/// converts an array of bytes to a string Hex representation
/// </summary>
internal static string ToHex(byte[] ba)
{
if (ba is null || ba.Length == 0)
{
return "";
}
const string HexFormat = "{0:X2}";
var sb = new StringBuilder();
foreach (byte b in ba)
sb.Append(string.Format(HexFormat, b));
return sb.ToString();
}
/// <summary>
/// converts from a string Hex representation to an array of bytes
/// </summary>
internal static byte[] FromHex(string hexEncoded)
{
if (hexEncoded is null || hexEncoded.Length == 0)
{
return null;
}
try
{
int l = Convert.ToInt32(hexEncoded.Length / 2d);
var b = new byte[l];
for (int i = 0, loopTo = l - 1; i <= loopTo; i++)
b[i] = Convert.ToByte(hexEncoded.Substring(i * 2, 2), 16);
return b;
}
catch (Exception ex)
{
throw new FormatException("The provided string does not appear to be Hex encoded:" + Environment.NewLine + hexEncoded + Environment.NewLine, ex);
}
}
/// <summary>
/// converts from a string Base64 representation to an array of bytes
/// </summary>
internal static byte[] FromBase64(string base64Encoded)
{
if (base64Encoded is null || base64Encoded.Length == 0)
{
return null;
}
try
{
return Convert.FromBase64String(base64Encoded);
}
catch (FormatException ex)
{
throw new FormatException("The provided string does not appear to be Base64 encoded:" + Environment.NewLine + base64Encoded + Environment.NewLine, ex);
}
}
/// <summary>
/// converts from an array of bytes to a string Base64 representation
/// </summary>
internal static string ToBase64(byte[] b)
{
if (b is null || b.Length == 0)
{
return "";
}
return Convert.ToBase64String(b);
}
}
#endregion
}

View File

@ -0,0 +1,87 @@
using System;
namespace Strata.Base.Internal
{
public class SecurityUtils
{
#region Declarations
private const string ENCRYPTION_KEY_SUFFIX = "SDT";
private const int KEY_SIZE_BYTES = 32; // 256 bits for AES-256
#endregion
#region Methods
private static string PadKey(string key)
{
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}
string paddedKey = key + ENCRYPTION_KEY_SUFFIX;
if (paddedKey.Length < KEY_SIZE_BYTES)
{
paddedKey = paddedKey.PadRight(KEY_SIZE_BYTES, 'X');
}
else if (paddedKey.Length > KEY_SIZE_BYTES)
{
paddedKey = paddedKey.Substring(0, KEY_SIZE_BYTES);
}
return paddedKey;
}
public static string EncryptValue(string value, string key)
{
if (value is null)
{
return null;
}
if (string.IsNullOrEmpty(value))
{
return string.Empty;
}
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}
// Create encryptor with default IV
var encryption = new EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.AES);
var result = encryption.Encrypt(new EncryptionUtils.Data(value), new EncryptionUtils.Data(PadKey(key)));
return result.Base64;
}
public static string DecryptValue(string encryptedValue, string key)
{
if (encryptedValue is null)
{
return null;
}
if (string.IsNullOrEmpty(encryptedValue))
{
return string.Empty;
}
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}
var encryption = new EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.AES);
// note EncryptValue returns Base64 string so we need to initialized encryptedData as Base64
var encryptedData = new EncryptionUtils.Data();
encryptedData.Base64 = encryptedValue;
return encryption.Decrypt(encryptedData, new EncryptionUtils.Data(PadKey(key))).Text;
}
#endregion
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,301 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Strata.Base.Internal</name>
</assembly>
<members>
<member name="T:Strata.Base.Internal.My.Resources.Resources">
<summary>
A strongly-typed resource class, for looking up localized strings, etc.
</summary>
</member>
<member name="P:Strata.Base.Internal.My.Resources.Resources.ResourceManager">
<summary>
Returns the cached ResourceManager instance used by this class.
</summary>
</member>
<member name="P:Strata.Base.Internal.My.Resources.Resources.Culture">
<summary>
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
</summary>
</member>
<member name="T:Strata.Base.Internal.EncryptionUtils.Hasher">
<summary>
Hash functions are fundamental to modern cryptography. These functions map binary
strings of an arbitrary length to small binary strings of a fixed length, known as
hash values. A cryptographic hash function has the property that it is computationally
infeasible to find two distinct inputs that hash to the same value. Hash functions
are commonly used with digital signatures and for data integrity.
</summary>
</member>
<member name="T:Strata.Base.Internal.EncryptionUtils.Hasher.Provider">
<summary>
Type of hash; some are security oriented, others are fast and simple
</summary>
</member>
<member name="F:Strata.Base.Internal.EncryptionUtils.Hasher.Provider.SHA256">
<summary>
Secure Hashing Algorithm provider, SHA-2 variant, 256-bit
</summary>
</member>
<member name="F:Strata.Base.Internal.EncryptionUtils.Hasher.Provider.SHA384">
<summary>
Secure Hashing Algorithm provider, SHA-2 variant, 384-bit
</summary>
</member>
<member name="F:Strata.Base.Internal.EncryptionUtils.Hasher.Provider.SHA512">
<summary>
Secure Hashing Algorithm provider, SHA-2 variant, 512-bit
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Hasher.#ctor(Strata.Base.Internal.EncryptionUtils.Hasher.Provider)">
<summary>
Instantiate a new hash of the specified type
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Hasher.Value">
<summary>
Returns the previously calculated hash
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Hasher.Calculate(System.IO.Stream@)">
<summary>
Calculates hash on a stream of arbitrary length
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Hasher.Calculate(Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Calculates hash for fixed length <see cref="T:Strata.Base.Internal.EncryptionUtils.Data"/>
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Hasher.Calculate(Strata.Base.Internal.EncryptionUtils.Data,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Calculates hash for a string with a prefixed salt value.
A "salt" is random data prefixed to every hashed value to prevent
common dictionary attacks.
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Hasher.CalculatePrivate(System.Byte[])">
<summary>
Calculates hash for an array of bytes
</summary>
</member>
<member name="T:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor">
<summary>
Symmetric encryption uses a single key to encrypt and decrypt.
Both parties (encryptor and decryptor) must share the same secret key.
</summary>
</member>
<member name="F:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Provider.AES">
<summary>
Advanced Encryption Standard (AES) provider
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.#ctor(Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Provider,System.Boolean)">
<summary>
Instantiates a new symmetric encryption object using the specified provider.
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.KeySizeBytes">
<summary>
Key size in bytes. We use the default key size for any given provider; if you
want to force a specific key size, set this property
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.KeySizeBits">
<summary>
Key size in bits. We use the default key size for any given provider; if you
want to force a specific key size, set this property
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Key">
<summary>
The key used to encrypt/decrypt data
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.IntializationVector">
<summary>
Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using
the value derived from the previous block; the first data block has no previous data block
to use, so it needs an InitializationVector to feed the first block
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.RandomInitializationVector">
<summary>
generates a random Initialization Vector, if one was not provided
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.RandomKey">
<summary>
generates a random Key, if one was not provided
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.ValidateKeyAndIv(System.Boolean)">
<summary>
Ensures that _crypto object has valid Key and IV
prior to any attempt to encrypt/decrypt anything
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Encrypt(Strata.Base.Internal.EncryptionUtils.Data,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Encrypts the specified Data using provided key
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Encrypt(Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Encrypts the specified Data using preset key and preset initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Encrypt(System.IO.Stream,Strata.Base.Internal.EncryptionUtils.Data,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Encrypts the stream to memory using provided key and provided initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Encrypt(System.IO.Stream,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Encrypts the stream to memory using specified key
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Encrypt(System.IO.Stream)">
<summary>
Encrypts the specified stream to memory using preset key and preset initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Decrypt(Strata.Base.Internal.EncryptionUtils.Data,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Decrypts the specified data using provided key and preset initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Decrypt(System.IO.Stream,Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Decrypts the specified stream using provided key and preset initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Decrypt(System.IO.Stream)">
<summary>
Decrypts the specified stream using preset key and preset initialization vector
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.SymmetricEncryptor.Decrypt(Strata.Base.Internal.EncryptionUtils.Data)">
<summary>
Decrypts the specified data using preset key and preset initialization vector
</summary>
</member>
<member name="T:Strata.Base.Internal.EncryptionUtils.Data">
<summary>
represents Hex, Byte, Base64, or String data to encrypt/decrypt;
use the .Text property to set/get a string representation
use the .Hex property to set/get a string-based Hexadecimal representation
</summary>
</member>
<member name="F:Strata.Base.Internal.EncryptionUtils.Data._encoding">
<summary>
Determines the default text encoding for this Data instance
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Data.#ctor">
<summary>
Creates new, empty encryption data
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Data.#ctor(System.Byte[])">
<summary>
Creates new encryption data with the specified byte array
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Data.#ctor(System.String)">
<summary>
Creates new encryption data with the specified string;
will be converted to byte array using UTF8 encoding
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Data.#ctor(System.String,System.Text.Encoding)">
<summary>
Creates new encryption data using the specified string and the
specified encoding to convert the string to a byte array.
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.IsEmpty">
<summary>
returns true if no data is present
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.StepBytes">
<summary>
allowed step interval, in bytes, for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.StepBits">
<summary>
allowed step interval, in bits, for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.MinBytes">
<summary>
minimum number of bytes allowed for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.MinBits">
<summary>
minimum number of bits allowed for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.MaxBytes">
<summary>
maximum number of bytes allowed for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.MaxBits">
<summary>
maximum number of bits allowed for this data; if 0, no limit
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.Bytes">
<summary>
Returns the byte representation of the data;
This will be padded to MinBytes and trimmed to MaxBytes as necessary!
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.Text">
<summary>
Sets or returns text representation of bytes using UTF8 encoding
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.Hex">
<summary>
Sets or returns Hex string representation of this data
</summary>
</member>
<member name="P:Strata.Base.Internal.EncryptionUtils.Data.Base64">
<summary>
Sets or returns Base64 string representation of this data
</summary>
</member>
<member name="T:Strata.Base.Internal.EncryptionUtils.Utils">
<summary>
Friend class for shared utility methods used by multiple Encryption classes
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Utils.ToHex(System.Byte[])">
<summary>
converts an array of bytes to a string Hex representation
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Utils.FromHex(System.String)">
<summary>
converts from a string Hex representation to an array of bytes
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Utils.FromBase64(System.String)">
<summary>
converts from a string Base64 representation to an array of bytes
</summary>
</member>
<member name="M:Strata.Base.Internal.EncryptionUtils.Utils.ToBase64(System.Byte[])">
<summary>
converts from an array of bytes to a string Base64 representation
</summary>
</member>
</members>
</doc>