Walter.Cypher 2023.9.14.812

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET 6.0 .NET Core 3.1
dotnet add package Walter.Cypher --version 2023.9.14.812
NuGet\Install-Package Walter.Cypher -Version 2023.9.14.812
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Walter.Cypher" Version="2023.9.14.812" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Walter.Cypher --version 2023.9.14.812
#r "nuget: Walter.Cypher, 2023.9.14.812"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Walter.Cypher as a Cake Addin
#addin nuget:?package=Walter.Cypher&version=2023.9.14.812

// Install Walter.Cypher as a Cake Tool
#tool nuget:?package=Walter.Cypher&version=2023.9.14.812

The cypher package for hashing data in a convenient and secure way as well as symmetric and asymmetric encryption methods. You can find On-line documentation at https://cypherapi.asp-waf.com/ as well as using the sample code found at https://github.com/ASP-WAF/Cypher

Cypher ICON Walter.Cypher

This repository shows how you can use the Walter.Cypher NuGet package in your code using little code snippets.

Walter.Web.CypherTests sample code

This sample code shows the use of

  1. Fixed cypher using a password to protect your code.
  2. Generating checksum for tamper detection.
  3. PGP using various key strengths to protect data
  4. The use of Numeric encryption that can be used to defeat base64 scanning tools to detect cyphered constants for password probing as values can be stored in int64 type values

Get Started

Show how to cipher large amounts of text using the Crypto class


[TestMethod()]
public void CipherZip()
{
    var sb = new StringBuilder();
    for (var i = 0; i < 1024; i++)
    {
        sb.Append(DateTime.Now.ToString());
    }
    var test = sb.ToString();

    var cypkered = Crypto.Zip(test);
    var expect = Crypto.UnZip(cypkered);
    Assert.AreEqual(test, expect);
}

Alternatively you can use the extension method

[TestMethod()]
public void CypherExtesnionTest()
{
    var testpw = "65654616540546546";
    var cypher = Environment.MachineName.Encrypt(testpw);
    var clear = cypher.Decrypt(testpw);

    Assert.AreEqual(Environment.MachineName, clear);
}

The extension method for cypher also allow encryption using public/private key encryption using certificates for text of any length

[TestMethod]
public void TestSmallStringAsBytes()
{
    using X509Certificate2 encryptCertificate = GetCert(".cer");
    using X509Certificate2 decryptCertificate = GetCert(".pfx", "01234456");

    var certCypher = Environment.MachineName.AsEncryptedBytes(encryptCertificate);
    var clearBytes = certCypher.AsDecryptFromBytes(decryptCertificate);

    Assert.AreEqual(Environment.MachineName, UTF8Encoding.UTF8.GetString(clearBytes));

    // helper method load embedded test certificate resource from assembly
    static X509Certificate2 GetCert(string extension, string password = null)
    {
        var asam = Assembly.GetExecutingAssembly();
        using (var memory = new MemoryStream())
        using (var stream = asam.GetManifestResourceStream(asam.GetManifestResourceNames().First(f => f.EndsWith(extension))))
        {
            stream.CopyTo(memory);
            return new X509Certificate2(memory.ToArray(), password);
        }
    }
}

[TestMethod]
public void TestLargeStringAsBytes()
{
    using X509Certificate2 encryptCertificate = GetCert(".cer");
    using X509Certificate2 cecryptCertificate = GetCert(".pfx","01234456");

    var sb = new StringBuilder();
    for (int i = 0; i < 100; i++)
    {
        sb.Append(Guid.NewGuid());
    }
    var text = sb.ToString();

    var certCypher = text.AsEncryptedBytes(encryptCertificate);
    Assert.AreNotEqual(certCypher.Length, text.Length);

    var clearBytes = certCypher.AsDecryptFromBytes(cecryptCertificate);
    Assert.AreEqual(text, UTF8Encoding.UTF8.GetString(clearBytes));

    X509Certificate2 GetCert(string extension, string password = null)
    {
        var asam = Assembly.GetExecutingAssembly();
        using (var memory = new MemoryStream())
        using (var stream = asam.GetManifestResourceStream(asam.GetManifestResourceNames().First(f => f.EndsWith(extension))))
        {
            stream!.CopyTo(memory);
            return new X509Certificate2(memory.ToArray(), password);
        }
    }
}


You also have the possibility to encrypt and decrypt persisted text based on the hosting machine, user executing the application, the application or process name this feature works on all platforms that support where that support the concept of users, processes and machine names in .NET and is ideal for storing secure data in memory that should not be possible to access when creating an application dump file but should survive a reboot.

There are some limitations on some IOT devices that might prevent you from using these features

public void RoundTrip_EncryptionScope_Process()
{
    var sb = new StringBuilder();
    for (int i = 0; i < 100; i++)
    {
        sb.Append(Guid.NewGuid());
    }
    var text = sb.ToString();

    var certCypher = text.AsEncryptedBytes(scope: EncryptionScope.Process);
    Assert.AreNotEqual(certCypher.Length, text.Length);

    var clearText = certCypher.AsDecryptFromBytes(scope: EncryptionScope.Process);
    Assert.AreEqual(text, clearText);

}

[TestMethod()]
public void RoundTrip_EncryptionScope_User()
{
    var sb = new StringBuilder();
    for (int i = 0; i < 100; i++)
    {
        sb.Append(Guid.NewGuid());
    }
    var text = sb.ToString();

    var certCypher = text.AsEncryptedBytes(scope: EncryptionScope.User);
    Assert.AreNotEqual(certCypher.Length, text.Length);

    var clearText = certCypher.AsDecryptFromBytes(scope: EncryptionScope.User);
    Assert.AreEqual(text, clearText);
}

[TestMethod()]
public void RoundTrip_EncryptionScope_Machine()
{
    var sb = new StringBuilder();
    for (int i = 0; i < 100; i++)
    {
        sb.Append(Guid.NewGuid());
    }
    var text = sb.ToString();

    var certCypher = text.AsEncryptedBytes(scope: EncryptionScope.Machine);
    Assert.AreNotEqual(certCypher.Length, text.Length);

    var clearText = certCypher.AsDecryptFromBytes(scope: EncryptionScope.Machine);
    Assert.AreEqual(text, clearText);
}

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Walter.Cypher:

Package Downloads
Walter.BOM The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Internal NuGet package with business objects used by several ASP-WAF products Documentation available at https://firewallapi.asp-waf.com/?topic=html/N-Walter.BOM.htm

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2023.9.14.812 105 9/14/2023
2023.8.29.1040 891 8/29/2023
2023.8.17.903 314 8/17/2023
2023.8.9.1314 403 8/9/2023
2023.8.2.750 478 8/2/2023
2023.7.12.830 523 7/12/2023
2023.7.5.1419 625 7/6/2023
2023.6.14.1628 1,137 6/14/2023
2023.5.30.1640 980 5/30/2023
2023.5.4.1552 1,086 5/4/2023
2023.4.12.1236 3,132 4/12/2023
2023.3.14.1356 2,771 3/14/2023
2023.3.1.810 1,693 3/1/2023
2023.2.25.1185 522 2/25/2023
2023.2.22.27 2,903 2/22/2023
2023.2.15.1413 1,851 2/15/2023
2023.2.11.1628 1,836 2/11/2023
2023.1.11.534 2,093 1/11/2023
2022.12.14.648 8,315 12/14/2022
2022.11.27.1059 2,526 11/27/2022
2022.11.21.338 2,627 11/21/2022
2022.11.14.1819 2,815 11/14/2022
2022.11.14.1533 495 11/14/2022
2022.11.13.917 3,280 11/13/2022
2022.10.31.740 5,312 11/1/2022
2022.10.15.652 5,655 10/15/2022
2022.10.1.810 7,103 10/1/2022
2022.9.26.1444 7,823 9/26/2022
2022.9.14.809 6,848 9/14/2022
2022.9.8.1009 13,206 9/8/2022
2022.8.20.1007 7,015 8/20/2022
2022.8.1.1 7,254 7/31/2022
2022.7.15.841 13,691 7/15/2022
2022.7.1.1300 7,307 7/1/2022
2022.6.21.647 7,265 6/21/2022
2022.5.4.1010 27,144 5/4/2022
2022.4.10.828 22,130 4/10/2022
2022.3.26.1117 22,100 3/26/2022
2022.2.11.931 38,843 2/17/2022
2022.1.15.1312 16,026 1/17/2022
2022.1.10.537 15,091 1/10/2022
2022.1.7.1357 6,894 1/8/2022
2021.12.28.1452 8,264 12/28/2021
2021.12.15.911 7,563 12/16/2021
2021.11.19.850 29,117 11/19/2021
2021.11.11.1334 23,421 11/16/2021
2021.11.8.2109 6,292 11/9/2021
2021.11.8.1612 6,864 11/8/2021
2021.10.23.1310 39,372 10/25/2021
2021.10.13.1459 7,194 10/18/2021
2021.10.9.821 382 10/10/2021
2021.9.26.1913 50,120 9/26/2021
2021.9.17.1702 11,516 9/18/2021
2021.8.30.1319 72,952 8/30/2021
2021.8.14.1600 39,908 8/16/2021
2021.8.14.829 4,234 8/14/2021
2021.8.8.1612 13,777 8/8/2021
2021.8.8.1138 363 8/8/2021
2021.7.22.1044 47,850 7/23/2021
2021.7.15.1547 7,159 7/15/2021
2021.7.12.734 7,086 7/13/2021
2021.6.26.1753 27,940 6/27/2021
2021.6.23.734 14,240 6/24/2021
2021.6.19.803 7,677 6/20/2021
2021.6.11.1600 27,943 6/13/2021
2021.6.9.1120 7,240 6/9/2021
2021.6.7.1407 1,952 6/7/2021
2021.5.28.1533 13,706 5/31/2021
2021.5.28.1451 7,211 5/31/2021
2021.5.25.1732 6,346 5/25/2021
2021.5.12.929 23,364 5/12/2021
2021.5.12.914 340 5/12/2021
2021.5.12.637 3,771 5/12/2021
2021.5.5.1901 23,398 5/6/2021
2021.5.2.1617 6,893 5/4/2021
2021.5.1.1505 7,106 5/1/2021
2021.4.28.1505 6,911 4/28/2021
2021.4.5.1653 46,731 4/5/2021
2021.4.1.913 7,037 4/1/2021
2021.3.31.1630 6,953 4/1/2021
2021.3.18.1608 7,374 3/18/2021
2021.3.3.1295 419 3/3/2021
2021.3.3.835 429 3/3/2021
2021.3.1.1205 18,241 3/2/2021
2021.3.1.1 12,762 2/27/2021
2021.2.21.1 12,271 2/21/2021
2021.2.19.3 6,593 2/20/2021
2021.2.19.2 6,308 2/19/2021
2021.2.18.2 5,829 2/19/2021
2021.2.18.1 385 2/19/2021
2021.2.16.1 12,770 2/16/2021
2021.2.10.1 29,219 2/10/2021
2021.2.9.1 5,240 2/9/2021
2021.2.8.1 411 2/9/2021
2021.2.7.1 10,365 2/6/2021
2020.12.27.1 9,855 12/27/2020
2020.12.26.3 13,924 12/27/2020
2020.12.26.2 432 12/27/2020
2020.12.24.2 463 12/26/2020
2020.12.24.1 417 12/24/2020
2020.12.18.1 5,540 12/19/2020
2020.12.15.1 9,994 12/15/2020
2020.12.14.5 9,208 12/14/2020
2020.12.14.4 5,208 12/14/2020
2020.12.14.3 4,974 12/14/2020
2020.11.27.1 52,460 11/27/2020
2020.11.25.1 9,710 11/25/2020
2020.11.23.1 428 11/25/2020
2020.11.22.2 6,604 11/23/2020
2020.11.20.1 5,971 11/21/2020
2020.11.19.3 6,037 11/19/2020
2020.11.11.1 48,267 11/11/2020
2020.10.9.5 105,037 10/9/2020
2020.10.5.1 52,713 10/5/2020
2020.10.4.1 472 10/4/2020
2020.10.1.1 13,601 10/1/2020
2020.9.24.2 17,104 9/24/2020
2020.9.12.1 36,037 9/12/2020
2020.9.8 12,015 9/8/2020
2020.9.6.5 3,558 9/6/2020
2020.9.6.4 471 9/6/2020
2020.9.6.2 1,628 9/6/2020
2020.9.3.1 9,580 9/3/2020

14 September 2023
     - SDK Service pack .net 6 and 7
     
     9 August 2023
     - Update to sevice packs of .net 6 and 7
     
     2 Augusted  2023
     - Update binaries

     14 June 2023
     - Update due to SDK Update 7.0.304, and 6.0.410

     31 May 2023
     - Update to new obfuscater version and MS Build update

     5 May 2023
     - Update due to new Obfuscation tool update

     14 Mar 2023
     - AddUpdate to latest Netwonsof t Json

     22 Feb 2023
     - Axel Imani Release (Go live)

     15 February 2023
     - Update to .net 6.0.406  and 7.0.3

     11 January 2023
     - update to 7.0.2, 6.0.13 SDK and build tools for 17.4.4
     - An SP for .net 3.1 was not provided by Microsoft at this time, we recommend migration away from 3.1 asap

     14 December 2022
     - Update to .Net SDK 3.1.426, 6.0.404 and 7.0.101

     27 November 2022
     - update package references

     21 November 2022
     - update to link NuGet changes .net 7.0

     14 November 2022
     - Update NuGet Packages
     - Link with .Net 7

     13 November 2022
     - Update NuGet packages
     - Remove support for pre-.net 6.0


     7 November 2022
     - Update to support .net 7

     31 October 2022
     - Update to build with new SDK

     1 October 2022
     - Update code sign certificate
     - Update SDK build


     14 September 2022
     - Update to include new package 6.0.2 and Microsoft CVE-2022-38013

     1 September 2022
     - Update MS build

     9 August 2022
     - update to SDK 6.0.400 / .Net 6.0.8 security patch
     - drop support for .net standard 2.0
     - drop support for .net 5.0

     15 June 2022
     - Update to support .net 6.0.7 and 3.1.27

     26 March 2022
     - Update NuGet package references

     27 December 2021
     - Enable Numeric cypher for .net 6.0


     15 December 2021
     - Update package references as well as .Net DSK release December 14 2021

     11 December 2021
     - Add extension method to encrypt using PGP RSA for Strings to byte[] and back

     6 December 2021
     - Add several extensions to the encryption extension helper method including certificate encryption/ decryption

     9 November 2021
     - Fix package dependency on vulnerable packages from Microsoft by upgrading vulnerable packages

     8 November 2021
     - Update to Microsoft packages 6.0.0, 5.0.403 and core 3.1.415

     11 October 2021
     - CodeSign the binaries as well as the NuGet package for executing in a trust-platform


     17 September 2021
     - Update NuGet Packages to the new release

     14 August 2021
     - Update NuGet package dependencies

     8 Aug 2021
     - update to .NET 6.0 SDK (v6.0.100-preview.6)

     22 June 2021
     - Change cypher methods to use the core types and not the managed types to be compatible with .Net 6.0
     - Include .Net 6.0 output

     15 June 2021
     - Update to .Net core 3.1.17 and :net 5.0.8
     .
     19 June 2021
     - Update package reference external dependencies

     25 May 2021
     - Update package reference external dependencies

     25 April 2021
     - Update Package references

     21 March 2021
     - Update Package references

     06 March 2021
     - Update Package references
     - Extend PGP allow export and import key
     - Add static method for PGPManaged

     01 February 2021
     - Update Package references

     18 February 2021
     - Add session PGP keyring support in PGPKeyGenerator (less secure for memory based attacks when a malicious user has access to the device)

     10 February 2021
     - Update package references
     - Add logging interface for extracting calling file name when faced with cypher errors

     30 January 2021
     - Update speed improvement
     - Update package references

     25 January 2021
     - Update extension methods
     - Update Package references

     02 January 2021
     - Updated license terms
     - Update Package references

     24 December 2020
     - Update Package references
     - Remove support for .net48

     15 December 2020
     - Update Package references

     19 November 2020
     1. Update package references

     11 November 2020
     1. Update package and add support for .net 5.0

     09 October 2020
     1. package update

     24 September 2020
     1. Update package references

     06  September 2020
     1. Set platform x64
     2. Update NuGet Package References

     26 August 2020
     1. Update dependency on NuGet packages

     12 August 2020 release
     1. Update dependency on NuGet packages

     13 June 2020 release
     1. Update exception reporting
     2. Update obfuscation settings to include file and line numbers

     11 June 2020 release
     1. Add Ticket service for incident reporting when the TicketService.ExceptionReporting is set to true (default false)

     2020.6.10.
     1. Update NuGet package License Manager

     2020.06.01. version contains
     1. Password based encryption
     2. Secured compressed data
     3. Asymmetric public, private data protection using key-rings with public and private key

     Probing cipher keys using exceptions are disabled by re-throwing exceptions removing the details that are used by attack vectors.

     Bugs fixed:
     1. Saving >4gb data is now supported