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
$ dotnet add package Walter.CypherIntroducing the WALTER Framework: Workable Algorithms for Location-aware Transmission, Encryption Response. Designed for modern developers, WALTER is a groundbreaking suite of NuGet packages crafted for excellence in .NET Standard 2.0, 2.1, Core 3.1, and .NET 6, 7, 8, as well as C++ environments. By integrating Delphi's native development strengths, we�ve enhanced WALTER�s encryption capabilities to be not only robust but also future-proof, ensuring that it excels in performance, stability, and cross-platform support.
Whether you're tackling networking, encryption, or secure communication, WALTER offers unparalleled efficiency and precision in processing, making it an essential tool for developers who prioritize speed, security, and memory management in their applications.
The Walter.Cypher package is a testament to our commitment to providing developers with state-of-the-art cryptographic capabilities. By leveraging Delphi�s potent native development environment, we�ve engineered the package to offer hashing, symmetric, and asymmetric encryption methods that are secure, efficient, and cross-platform. This ensures that data encrypted with Walter.Cypher remains secure against both current and emergent cyber threats, including those posed by quantum computing advancements.
For detailed insights into how Delphi underpins our cryptographic solutions, offering a blend of speed, efficiency, and future-readiness, refer to the DelphiInside.md document. This document elaborates on our strategic choice of Delphi for native calls and AoT compilation, ensuring that the Walter.Cypher package delivers exceptional performance and security across all platforms.
Online documentation and sample code are available to help you integrate Walter.Cypher into your projects seamlessly.
This repository showcases how to utilize the Walter.Cypher NuGet package effectively in your projects with minimal code snippets.
This sample code shows the use of
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);
}