PelindoEncryptCore 0.0.0.1

Encrypt and Decrpty tool,Include AES,RSA,MD5,SAH1,SAH256,SHA384,SHA512, BASE64, and DataProtector For ASPNETCore

Install-Package PelindoEncryptCore -Version 0.0.0.1
dotnet add package PelindoEncryptCore --version 0.0.0.1
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.0.1 607 4/12/2018