Git Product home page Git Product logo

rijndael256's Introduction

Rijndael256

NuGet Build Status

AES cryptographic library for .NET Framework and .NET Core


About

Rijndael256 makes encrypting data and files a breeze with the AES symmetric-key cipher Rijndael.

Features

  • Advanced Encryption Standard (AES)
  • Rijndael symmetric-key cipher:
    • Encrypt data or files
    • AES key sizes:
      • 128-bit
      • 192-bit
      • 256-bit
    • CBC Mode
  • Authenticated Encryption (AE)
    • Encrypt-then-MAC (EtM)
  • Cryptographic hashes:
    • SHA-512
    • PBKDF2

Quick Start

Encrypt a string using Rijndael AES 256-bit

string password = "sKzvYk#1Pn33!YN";  // The password to encrypt the data with
string plaintext = "Top secret data"; // The string to encrypt

// Encrypt the string
string ciphertext = Rijndael.Encrypt(plaintext, password, KeySize.Aes256);

// Decrypt the string
plaintext = Rijndael.Decrypt(ciphertext, password, KeySize.Aes256);

Encrypt a string using Authenticated Encryption (AE)

string password = "KQpc@HuQ66b$z37";  // The password to encrypt the data with
string plaintext = "Top secret data"; // The string to encrypt

// Encrypt the string
string aeCiphertext = RijndaelEtM.Encrypt(plaintext, password, KeySize.Aes256);

// Decrypt the string
plaintext = RijndaelEtM.Decrypt(aeCiphertext, password, KeySize.Aes256);

Encrypt a file using Rijndael AES 256-bit

string password = "2zj9cV!50BwJ$A1";            // The password to encrypt the file with
string plaintextFile = @"C:\TopSecretFile.png"; // The file to encrypt
string ciphertextFile = @"C:\SecureFile";       // The encrypted file (extension unnecessary)

// Encrypt the file
Rijndael.Encrypt(plaintextFile, ciphertextFile, password, KeySize.Aes256);

// Decrypt the file
Rijndael.Decrypt(ciphertextFile, plaintextFile, password, KeySize.Aes256);

Settings

The Settings object is a collection of mutable defaults used throughout the library. Modification of these defaults is not necessary, but is made available for developers who want finer control of Rijndael256.

Setting Description Default
HashIterations The number of iterations used to derive hashes 10000

Example

// The HashIterations setting is used in several places throughout the lib,
// with Rijndael.Encrypt being just one of them. After making this change,
// any future calls to Rijndael.Encrypt will make use of this new value
Settings.HashIterations = 25000;

// To reset all the settings to their default values
Settings.Reset();

Appendix

Authenticated Encryption (AE)

AE adds an integrity check to the resulting ciphertext, so we can authenticate the ciphertext before decrypting it. Whereas encryption provides confidentiality, AE adds authenticity.

Encrypt-then-MAC (EtM)

Rijndael256 offers AE via the EtM encryption mode, which was standardized in ISO/IEC 19772:2009.

EtM Workflow
  1. Encryption:
    1. The plaintext is encrypted.
    2. A MAC is calculated from the resulting ciphertext.
    3. The MAC is appended to the ciphertext.
  2. Decryption:
    1. The MAC is extracted from the ciphertext (Mo).
    2. A MAC is calculated from the ciphertext (Mn).
    3. The MACs are compared for equality (Mo == Mn)
      1. Equal: The ciphertext is decrypted.
      2. Not Equal: Authentication has failed -- the decryption process is aborted, with no attempt being made to decrypt the unauthentic ciphertext.

rijndael256's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rijndael256's Issues

Add Reset method to Settings

Acceptance Criteria

  1. Calling Settings.Reset() restores all settings to their default values
  2. Unit test coverage

specified padding mode is not valid for this algorithm

I have a project in vb.net framework version 4.5. I am upgrading my project to ASP.Net Core 1.1 and trying to decry-pt the same encrypted code of framework 4.5 in ASP.Net Core and getting exception

"specified padding mode is not valid for this algorithm"
I have used the Rijndael algorithm for encryption/decryption of data in Asp.Net Framework 4.5 and still using Rijndael in ASP.Net Core for encryption/decryption but getting issue.

Can anyone help me to find-out the reason behind this issue.

Thanks

Rename Config to Settings

Acceptance Criteria

  1. The Config class is renamed to Settings
  2. The ConfigTests class is renamed to SettingsTests
  3. Comments and README reference Settings instead of Config

About support for .NET Core 1.0

I have done a branch for porting back the project to Visual Studio 2015 and change supported frameworks to .NET Standard 1.3 and .NET Framework 4.5.1.
See any possibility to merge back to the main repo?
This is my fork.

add-type A namespace cannot directly contain members such as fields or methods

when using powershell core to add-type like this:

$modulepath= Resolve-Path -path "$PSScriptRoot\lib\netstandard1.3\Rijndael256.dll"

add-type $modulepath

function Encrypt-Rijndael256{
    param(
        $key,
        $plaintext
    )

    return [Rijndael256.Rijndael]::Encrypt($plaintext,$key,256)
}

function Decrypt-Rijndael256{
    param(
        $key,
        $encryptText
        
    )
    return [Rijndael256.Rijndael]::Decrypt($encryptText,$key,256)
}

### i always got error like this.
add-type : (1) : Type or namespace definition, or end-of-file expected
(1) : >>> /home/yoke/Documents/PSPHPIPAM/functions/lib/netstandard1.3/Rijndael256.dll
At /home/yoke/Documents/PSPHPIPAM/functions/Rijndael256.core.ps1:3 char:1
+ add-type $modulepath
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

maybe the below link can show what's wrong there
here

.NET Core 3.1 - Initialization vector 256 bits not supported

Hey,

If .NET Core 3.1 still does not support 256 initialization vector why documentation does not reflect that?

Look at this:

//RijndaelManaged
// Legal min key size = 128
// Legal max key size = 256
// Legal min block size = 128
// Legal max block size = 256

Anybody can't get the same result! Why does the documentation is not refleting the truth?

https://docs.microsoft.com/pt-br/dotnet/api/system.security.cryptography.symmetricalgorithm.legalkeysizes?view=netcore-3.1

Originally posted by @dericferreira in #13 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.