SimpleSecureData 1.0.0

dotnet add package SimpleSecureData --version 1.0.0                
NuGet\Install-Package SimpleSecureData -Version 1.0.0                
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="SimpleSecureData" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleSecureData --version 1.0.0                
#r "nuget: SimpleSecureData, 1.0.0"                
#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 SimpleSecureData as a Cake Addin
#addin nuget:?package=SimpleSecureData&version=1.0.0

// Install SimpleSecureData as a Cake Tool
#tool nuget:?package=SimpleSecureData&version=1.0.0                

🔒 SimpleSecureData

SimpleSecureData is a cross-platform library designed to enhance security by ensuring sensitive data remains encrypted in memory at all times. It leverages platform-specific secure storage mechanisms for optimal security and falls back to a custom AES-based encryption for unsupported platforms.


📖 Table of Contents

  1. 🚀 Features
  2. 💾 Platform-Specific Implementations
  3. 📦 Installation
  4. 📚 Usage Examples
  5. 🤝 Contributing
  6. 📜 License

🚀 Features

  • Memory Encryption: All sensitive data is encrypted in memory using ChaCha20.
  • Platform-Specific Secure Storage:
    • Windows: DPAPI for secure local storage.
    • Android: AndroidX EncryptedSharedPreferences.
    • iOS: Keychain Services.
  • Secure Data Types:
    • SecureBytes: Securely manage byte arrays.
    • SecureString: A secure implementation for strings.
    • SecureChar: Handle individual characters securely.
  • Cross-Platform Support: Supports Windows, Android, iOS, macOS, Linux, and more.
  • Fallback Mechanism: AES-based encryption with HMAC for platforms without secure storage APIs.
  • Flexible APIs:
    • Serialize, deserialize, append, and split secure objects.
    • Automatic memory cleanup with CryptographicOperations.ZeroMemory.

💾 Platform-Specific Implementations

Platform Implementation
Windows DPAPI (System.Security.Cryptography.ProtectedData).
Android AndroidX EncryptedSharedPreferences with AES-256-GCM.
iOS Keychain Services for secure storage.
Others AES-256 encryption with HMAC for integrity verification (fallback).

📦 Installation

  1. Add the package to your project:

    dotnet add package SimpleSecureData
    
  2. Import the necessary namespaces:

    using SimpleSecureData;
    using SimpleSecureData.Text;
    

📚 Usage Examples

SecureBytes

Securely store and manipulate byte arrays:

var secureBytes = new SecureBytes(new byte[] { 1, 2, 3, 4 });
secureBytes.AppendData(new byte[] { 5, 6, 7 });
byte[] plainBytes = secureBytes.GetBytes(); // Decrypt to access data
secureBytes.Dispose(); // Clean up memory

SecureString

Handle strings securely in memory:

var secureString = new SecureString("SensitiveData");
secureString.AppendData(" MoreData");

// Retrieve as plain text (temporarily)
string plainText = secureString.ToString();

secureString.Dispose(); // Clean up memory

Platform-Secure Storage

Store and retrieve secrets using platform-specific secure storage:

byte[] sensitiveData = Encoding.UTF8.GetBytes("Sensitive Data");

// Store data securely
Guid secretId = PlatformSecureStorage.StoreSecret(sensitiveData);

// Retrieve data securely
byte[] retrievedData = PlatformSecureStorage.RetrieveSecret(secretId);

// Remove secret
PlatformSecureStorage.RemoveSecret(secretId);

🔧 Technical Notes

  • Windows (DPAPI):
    • Data is encrypted with ProtectedData using DataProtectionScope.CurrentUser.
  • Android:
    • Uses AndroidX EncryptedSharedPreferences with AES-256-GCM and HMAC.
  • iOS:
    • Integrates with the Keychain to securely store and retrieve data.
  • Fallback Mechanism:
    • AES-256 with HMAC for encryption and integrity verification.
  • ChaCha20 Encryption:
    • Used for in-memory encryption with optional Associated Data (AAD).

🤝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-browser1.0 is compatible.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst18.0 is compatible.  net8.0-macos was computed.  net8.0-macos15.0 is compatible.  net8.0-tvos was computed.  net8.0-tvos18.0 is compatible.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 43 1/24/2025

- Secure Data Types: Added SecureBytes, SecureString, SecureChar, and other secure data types for safe handling of sensitive information.
- Platform-Specific Security:
 + Windows: DPAPI integration for secure local storage.
 + Android: Uses EncryptedSharedPreferences with AES-256-GCM.
 + iOS: Supports Keychain Services.
 + Fallback Mechanism: Provides AES-based encryption for unsupported platforms.
- Key Management: Automatic key generation and storage using platform-secure methods.
- Flexible APIs:
 + Append, split, and transform secure strings.
 + Serialize and deserialize secure objects.
- Cross-Platform Support: Windows, Android, iOS, macOS, Linux, and more.