LaraCryptSharp 1.0.0

dotnet add package LaraCryptSharp --version 1.0.0
                    
NuGet\Install-Package LaraCryptSharp -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="LaraCryptSharp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LaraCryptSharp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LaraCryptSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LaraCryptSharp --version 1.0.0
                    
#r "nuget: LaraCryptSharp, 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.
#:package LaraCryptSharp@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LaraCryptSharp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LaraCryptSharp&version=1.0.0
                    
Install as a Cake Tool

LaraCryptSharp

NuGet Build status License: MIT

LaraCryptSharp is a .NET library designed to facilitate seamless encryption and decryption of strings compatible with Laravel's encryption mechanisms. It aims to provide an easy-to-use interface for .NET applications that need to interact with data encrypted by Laravel applications, or vice versa.

Features

  • Encrypt: Encrypt plain text using AES-256-CBC algorithm, generating a payload that includes the IV (Initialization Vector) and the encrypted data.
  • Decrypt: Decrypt payloads encrypted by Laravel (assuming no MAC check is required), allowing for seamless data exchange between Laravel and .NET applications.

Getting Started

To use LaraCryptSharp in your project, include the LaraCryptSharp namespace and utilize the Cipher class for encryption and decryption tasks.

Installation

LaraCryptSharp is available for download as a package from NuGet, allowing for easy integration into your projects. Alternatively, you can clone the repository or directly copy the code into your project if needed.

Usage

Encrypting a String
using LaraCryptSharp;

string plainText = "Hello, world!";
string key = "YourBase64EncodedLaravelAppKey"; // Laravel app key without 'base64:' prefix

string encryptedPayload = Cipher.Encrypt(plainText, key);
Console.WriteLine($"Encrypted Payload: {encryptedPayload}");
Decrypting a String
using LaraCryptSharp;

string encryptedPayload = "YourEncryptedPayloadHere";
string key = "YourBase64EncodedLaravelAppKey"; // Laravel app key without 'base64:' prefix

string decryptedText = Cipher.Decrypt(encryptedPayload, key);
Console.WriteLine($"Decrypted Text: {decryptedText}");

Notes

  • The encryption function generates a new IV for each encryption operation and constructs a payload similar to Laravel's, including the IV and the encrypted data.
  • The decryption function is designed to work with payloads encrypted by Laravel, assuming no MAC (Message Authentication Code) verification is required.
  • Ensure the key used for encryption and decryption matches the Laravel application key used to encrypt the data.

Contributing

Contributions are welcome! If you have suggestions or improvements, feel free to fork the repository and submit a pull request.

License

LaraCryptSharp is open-source software licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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 445 4/11/2024