PelindoEncryptCore 0.0.0.1

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

// Install PelindoEncryptCore as a Cake Tool
#tool nuget:?package=PelindoEncryptCore&version=0.0.0.1                

PelindoEncryptCore

ASPNET CORE Encrypt and Decrpty tool,Include AES,RSA,MD5,SAH1,SAH256,SHA384,SHA512, BASE64, DataProtector and more

To install PelindoEncryptCore, run the following command in the Package Manager Console

Install-Package PelindoEncryptCore -Version 0.0.0.1

Easy to use with EncryptProvider

AES

Create AES Key
var aseKey = EncryptProvider.CreateAesKey();

var key = aesKey.Key;
var iv = aesKey.IV;
AES encrypt
  • AES encrypt without iv

    var srcString = "aes encrypt";
    var encrypted = EncryptProvider.AESEncrypt(srcString, key);
    
    
  • AES encrypt with iv

    var srcString = "aes encrypt";
    var encrypted = EncryptProvider.AESEncrypt(srcString, key, iv);
    
    
  • AES encrypt bytes at version 2.0.6

    var srcBytes = new byte[]{xxx};
    var encryptedBytes = EncryptProvider.AESEncrypt(srcBytes, key, iv);
    
    
ASE decrypt
  • AES decrypt without iv

    var encryptedStr = "xxxx";
    var decrypted = EncryptProvider.AESDecrypt(encryptedStr, key);
    
  • AES decrypt with iv

    var encryptedStr = "xxxx";
    var decrypted = EncryptProvider.AESDecrypt(encryptedStr, key, iv);
    
  • AES decrypt bytes at version 2.0.6

    var encryptedBytes =  new byte[]{xxx};
    var decryptedBytes = EncryptProvider.AESDecrypt(encryptedBytes, key, iv);
    

DES (version 2.0.2)

  • Create DES Key
    
    //des key length is 24 bit
    var desKey = EncryptProvider.CreateDesKey();
    
    
  • DES encrypt
    var srcString = "des encrypt";
    var encrypted = EncryptProvider.DESEncrypt(srcString, key);
    
  • DES encrypt bytes at version 2.0.6
    var srcBytes =  new byte[]{xxx};
    var decryptedBytes = EncryptProvider.DESEncrypt(srcBytes, key);
    
  • DES decrypt
    var encryptedStr = "xxxx";
    var decrypted = EncryptProvider.DESDecrypt(encryptedStr, key);
    
  • DES decrypt bytes at version 2.0.6
    var encryptedBytes =  new byte[]{xxx};
    var decryptedBytes = EncryptProvider.DESDecrypt(encryptedBytes, key);
    

RSA

  • Enum RsaSize
     public enum RsaSize
    {
        R2048=2048,
        R3072=3072,
        R4096=4096
    }
    
  • Create RSA Key with RsaSize(update at version 2.0.1)
    var rsaKey = EncryptProvider.CreateRsaKey();    //default is 2048
    
    // var rsaKey = EncryptProvider.CreateRsaKey(RsaSize.R3072);
    
    var publicKey = rsaKey.PublicKey;
    var privateKey = rsaKey.PrivateKey;
    var exponent = rsaKey.Exponent;
    var modulus = rsaKey.Modulus;
    
  • RSA encrypt
    var publicKey = rsaKey.PublicKey;
    var srcString = "rsa encrypt";
    
    
    var encrypted = EncryptProvider.RSAEncrypt(publicKey, srcString);
    
    // On mac/linux at version 2.0.5
    var encrypted = EncryptProvider.RSAEncrypt(publicKey, srcString, RSAEncryptionPadding.Pkcs1);
    
  • RSA decrypt
    var privateKey = rsaKey.PrivateKey;
    var encryptedStr = "xxxx";
    
    var decrypted = EncryptProvider.RSADecrypt(privateKey, encryptedStr);
    
    // On mac/linux at version 2.0.5
    var decrypted = EncryptProvider.RSADecrypt(privateKey, encryptedStr, RSAEncryptionPadding.Pkcs1);
    
  • RSA from string (add at version 2.0.1)
    var privateKey = rsaKey.PrivateKey;
    RSA rsa = EncryptProvider.RSAFromString(privateKey);
    

MD5


var srcString = "Md5 hash";
var hashed = EncryptProvider.Md5(srcString);


var srcString = "Md5 hash";
var hashed = EncryptProvider.Md5(srcString, MD5Length.L16);

SHA

  • SHA1
    var srcString = "sha hash";    
    var hashed = EncryptProvider.Sha1(srcString); 
    
  • SHA256
    var srcString = "sha hash";    
    var hashed = EncryptProvider.Sha256(srcString); 
    
  • SHA384
    var srcString = "sha hash";    
    var hashed = EncryptProvider.Sha384(srcString); 
    
  • SHA512
    var srcString = "sha hash";    
    var hashed = EncryptProvider.Sha512(srcString);
    

HMAC

  • HMAC-MD5
    var key="xxx";
    var srcString = "hmac md5 hash";     
    var hashed = EncryptProvider.HMACMD5(srcString,key);
    
  • HMAC-SHA1
    var key="xxx";
    var srcString = "hmac sha hash";    
    var hashed = EncryptProvider.HMACSHA1(srcString,key);
    
  • HMAC-SHA256
    var key="xxx";
    var srcString = "hmac sha hash";    
    var hashed = EncryptProvider.HMACSHA256(srcString,key);
    
  • HMAC-SHA384
    var key="xxx";
    var srcString = "hmac sha hash";    
    var hashed = EncryptProvider.HMACSHA384(srcString,key);
    
  • HMAC-SHA512
    var key="xxx";
    var srcString = "hmac sha hash";    
    var hashed = EncryptProvider.HMACSHA512(srcString,key);
    

Base64

  • Base64Encrypt
    var srcString = "base64 string";    
    var hashed = EncryptProvider.Base64Encrypt(srcString);   //default encoding is UTF-8
    
    var srcString = "base64 string";    
    var hashed = EncryptProvider.Base64Encrypt(srcString,Encoding.ASCII);  
    
  • Base64Decrypt
    var encryptedStr = "xxxxx";    
    var strValue = EncryptProvider.Base64Decrypt(encryptedStr);   //default encoding is UTF-8
    
    var encryptedStr = "xxxxx";    
    var strValue = EncryptProvider.Base64Decrypt(encryptedStr,Encoding.ASCII); 
    

Easy to use hash with EncryptExtensions

MD5 Extensions

  • String to MD5

var hashed="some string".MD5();

SHA Extensions

  • String to SHA1

var hashed="some string".SHA1();

Tips:SHA256,SHA384,SHA512 the same usage like SHA1

HMACSHA Extensions

  • String to HMACSHA1

var key="xxx";
var hashed="some string".HMACSHA1(key);

Tips:HMACSHA256,HMACSHA384,HMACSHA512 the same usage like HMACSHA1

LICENSE

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 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
0.0.0.1 1,413 4/12/2018