SecureStringExtensions.NetStandard
1.0.0
dotnet add package SecureStringExtensions.NetStandard --version 1.0.0
NuGet\Install-Package SecureStringExtensions.NetStandard -Version 1.0.0
<PackageReference Include="SecureStringExtensions.NetStandard" Version="1.0.0" />
paket add SecureStringExtensions.NetStandard --version 1.0.0
#r "nuget: SecureStringExtensions.NetStandard, 1.0.0"
// Install SecureStringExtensions.NetStandard as a Cake Addin #addin nuget:?package=SecureStringExtensions.NetStandard&version=1.0.0 // Install SecureStringExtensions.NetStandard as a Cake Tool #tool nuget:?package=SecureStringExtensions.NetStandard&version=1.0.0
Secure string extensions
These methods help converting SecureString into character array or string or the other way around, from string or character arrays into SecureString.
It is recommended to avoid strings if possible and stick to only using character arrays (or pointer to these arrays) as strings are inherently unsafe. Using SecureString in tandem with string beats much of the purpose of SecureString, which is kept in encrypted unmanaged memory and strings, which are kept possibly multiple places in managed memory and memory allocated values are in plaintext.
This library is compiled with .NET Standard so it can be used with and .NET, .NET Framework and .NET Core which supports .NET Standard 2.0.
To use the methods add this using to your source code:
using SecureStringExtensions;
The methods will then show up as extension methods on char[] and string instances.
The following tests shows how to use the lib.
using NUnit.Framework;
using System;
using SecureStringExtensions;
using System.Security;
namespace SecureStringExtensions.Test
{
[TestFixture]
public class SecureStringExtensionsTest
{
[Test]
[TestCase(new char[] { 'G', 'O', 'A', 'T', '1', '2', '3' })]
public void CopyCharArrayToSecureStringAndCopyBackToCharArrayReturnsExpected(char[] inputChars)
{
SecureString sec = inputChars.ToSecureString();
var copiedFromSec = sec.FromSecureStringToCharArray();
CollectionAssert.AreEqual(copiedFromSec, inputChars);
}
[Test]
[TestCase("GOAT456")]
public void CopyStringToSecureStringAndCopyBackToUnsafeStringReturnsExpected(string inputString)
{
SecureString sec = inputString.ToSecureString();
var copiedFromSec = sec.FromSecureStringToUnsafeString();
Assert.AreEqual(copiedFromSec, inputString);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 340 | 7/21/2021 |
Summary of changes made in this release of the package.