Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

NETCore encrypt and decrypt tool,Include aes,des,rsa,md5,sha1,sha256,sha384,sha512

License

NotificationsYou must be signed in to change notification settings

myloveCc/NETCore.Encrypt

Repository files navigation

NuGetNET 6.0NetStandard 2.1licenseGitHub-Actions-Img

NETCore encrypt and decrypt tool,Include AES,RSA,MD5,SAH1,SAH256,SHA384,SHA512 and more

To install NETCore.Encrypt, run the following command in thePackage Manager Console

Package Manager

Install-Package NETCore.Encrypt -Version 2.1.1

.NET CLI

dotnet add package NETCore.Encrypt --version 2.1.1

PackageReference

<PackageReference Include="NETCore.Encrypt" Version="2.1.1" />

Easy to use withEncryptProvider

AES

Create AES Key

varaesKey=EncryptProvider.CreateAesKey();varkey=aesKey.Key;variv=aesKey.IV;

AES encrypt

  • AES encrypt without iv (ECB mode)

    varsrcString="aes encrypt";varencrypted=EncryptProvider.AESEncrypt(srcString,key);
  • AES encrypt with iv (CBC mode)

    varsrcString="aes encrypt";varencrypted=EncryptProvider.AESEncrypt(srcString,key,iv);
  • AES encrypt bytes with iv (CBC mode)

    varsrcBytes=newbyte[]{xxx};varencryptedBytes=EncryptProvider.AESEncrypt(srcBytes,key,iv);

ASE decrypt

  • AES decrypt without iv (ECB mode)

    varencryptedStr="xxxx";vardecrypted=EncryptProvider.AESDecrypt(encryptedStr,key);
  • AES decrypt with iv (CBC mode)

    varencryptedStr="xxxx";vardecrypted=EncryptProvider.AESDecrypt(encryptedStr,key,iv);
  • AES decrypt bytes with iv (CBC mode)

    varencryptedBytes=newbyte[]{xxx};vardecryptedBytes=EncryptProvider.AESDecrypt(encryptedBytes,key,iv);

DES

  • Create DES Key

    //des key length is 24 bitvardesKey=EncryptProvider.CreateDesKey();
  • Create DES Iv 【NEW】

    //des iv length is 8 bitvardesIv=EncryptProvider.CreateDesIv();
  • DES encrypt (ECB mode)

    varsrcString="des encrypt";varencrypted=EncryptProvider.DESEncrypt(srcString,key);
  • DES encrypt bytes (ECB mode)

    varsrcBytes=newbyte[]{xxx};vardecryptedBytes=EncryptProvider.DESEncrypt(srcBytes,key);
  • DES decrypt (ECB mode)

    varencryptedStr="xxxx";vardecrypted=EncryptProvider.DESDecrypt(encryptedStr,key);
  • DES decrypt bytes (ECB mode)

    varencryptedBytes=newbyte[]{xxx};vardecryptedBytes=EncryptProvider.DESDecrypt(encryptedBytes,key);
  • DES encrypt bytes with iv (CBC mode)【NEW】

    varsrcBytes=newbyte[]{xxx};varencrypted=EncryptProvider.DESEncrypt(srcBytes,key,iv);
  • DES decrypt bytes with iv (CBC mode)【NEW】

    varencryptedBytes=newbyte[]{xxx};varencrypted=EncryptProvider.DESDecrypt(encryptedBytes,key,iv);

RSA

  • Enum RsaSize

    publicenumRsaSize{R2048=2048,R3072=3072,R4096=4096}
  • Create RSA Key with RsaSize

    varrsaKey=EncryptProvider.CreateRsaKey();//default is 2048// var rsaKey = EncryptProvider.CreateRsaKey(RsaSize.R3072);varpublicKey=rsaKey.PublicKey;varprivateKey=rsaKey.PrivateKey;varexponent=rsaKey.Exponent;varmodulus=rsaKey.Modulus;
  • Rsa Sign and Verify method

    stringrawStr="xxx";stringsignStr=EncryptProvider.RSASign(rawStr,privateKey);boolresult=EncryptProvider.RSAVerify(rawStr,signStr,publicKey);
  • RSA encrypt

    varpublicKey=rsaKey.PublicKey;varsrcString="rsa encrypt";varencrypted=EncryptProvider.RSAEncrypt(publicKey,srcString);// On mac/linux at version 2.0.5varencrypted=EncryptProvider.RSAEncrypt(publicKey,srcString,RSAEncryptionPadding.Pkcs1);
  • RSA decrypt

    varprivateKey=rsaKey.PrivateKey;varencryptedStr="xxxx";vardecrypted=EncryptProvider.RSADecrypt(privateKey,encryptedStr);// On mac/linux at version 2.0.5vardecrypted=EncryptProvider.RSADecrypt(privateKey,encryptedStr,RSAEncryptionPadding.Pkcs1);
  • RSA from string

    varprivateKey=rsaKey.PrivateKey;RSArsa=EncryptProvider.RSAFromString(privateKey);
  • RSA with PEM

    //Rsa to pem format key//PKCS1 pemvarpkcs1KeyTuple=EncryptProvider.RSAToPem(false);varpublicPem=pkcs1KeyTuple.publicPem;varprivatePem=pkcs1KeyTuple.privatePem;//PKCS8 pemvarpkcs8KeyTuple=EncryptProvider.RSAToPem(true);publicPem=pkcs8KeyTuple.publicPem;privatePem=pkcs8KeyTuple.privatePem;//Rsa from pem keyvarrsa=EncryptProvider.RSAFromPem(pemPublicKey);rsa=EncryptProvider.RSAFromPem(pemPrivateKey);//Rsa encrypt and decrypt with pem keyvarrawStr="xxx";varenctypedStr=EncryptProvider.RSAEncryptWithPem(pemPublicKey,rawStr);vardecryptedStr=EncryptProvider.RSADecryptWithPem(pemPrivateKey,enctypedStr);
  • RSA with PKCS #1 / PKCS #8

    //Rsa to pkcs1 format key//PKCS1varpkcs1KeyTuple=EncryptProvider.RsaToPkcs1();varpublicPkcs1=pkcs1KeyTuple.publicPkcs1;varprivatePkcs1=pkcs1KeyTuple.privatePkcs1;//Rsa to pkcs8 format key//PKCS8varpkcs8KeyTuple=EncryptProvider.RsaToPkcs8();varpublicPkcs8=pkcs1KeyTuple.publicPkcs8;varprivatePkcs8=pkcs1KeyTuple.privatePkcs8;//Rsa from pkcs public keyvarrsa=EncryptProvider.RSAFromPublicPkcs(pkcsPublicKey);// Pkcs #1 | Pkcs #8rsa=EncryptProvider.RSAFromPrivatePkcs1(privatePkcs1);rsa=EncryptProvider.RSAFromPrivatePkcs8(privatePkcs8);//Rsa encrypt and decrypt with pkcs key

MD5

varsrcString="Md5 hash";varhashed=EncryptProvider.Md5(srcString);
varsrcString="Md5 hash";varhashed=EncryptProvider.Md5(srcString,MD5Length.L16);

SHA

  • SHA1

    varsrcString="sha hash";varhashed=EncryptProvider.Sha1(srcString);
  • SHA256

    varsrcString="sha hash";varhashed=EncryptProvider.Sha256(srcString);
  • SHA384

    varsrcString="sha hash";varhashed=EncryptProvider.Sha384(srcString);
  • SHA512

    varsrcString="sha hash";varhashed=EncryptProvider.Sha512(srcString);

HMAC

  • HMAC-MD5

    varkey="xxx";varsrcString="hmac md5 hash";    varhashed=EncryptProvider.HMACMD5(srcString,key);
  • HMAC-SHA1

    varkey="xxx";varsrcString="hmac sha hash";varhashed=EncryptProvider.HMACSHA1(srcString,key);
  • HMAC-SHA256

    varkey="xxx";varsrcString="hmac sha hash";varhashed=EncryptProvider.HMACSHA256(srcString,key);
  • HMAC-SHA384

    varkey="xxx";varsrcString="hmac sha hash";varhashed=EncryptProvider.HMACSHA384(srcString,key);
  • HMAC-SHA512

    varkey="xxx";varsrcString="hmac sha hash";varhashed=EncryptProvider.HMACSHA512(srcStringkey);

Base64

  • Base64Encrypt

    varsrcString="base64 string";varhashed=EncryptProvider.Base64Encrypt(srcString);//default encoding is UTF-8
    varsrcString="base64 string";varhashed=EncryptProvider.Base64Encrypt(srcString,Encoding.ASCII);
  • Base64Decrypt

    varencryptedStr="xxxxx";varstrValue=EncryptProvider.Base64Decrypt(encryptedStr);//default encoding is UTF-8
    varencryptedStr="xxxxx";varstrValue=EncryptProvider.Base64Decrypt(encryptedStr,Encoding.ASCII);

Easy to use hash withEncryptExtensions

MD5 Extensions

  • String to MD5

varhashed="some string".MD5();

SHA Extensions

  • String to SHA1

varhashed="some string".SHA1();

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

HMACSHA Extensions

  • String to HMACSHA1

 varkey="xxx"; varhashed="some string".HMACSHA1(key);

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

LICENSE

MIT License

About

NETCore encrypt and decrypt tool,Include aes,des,rsa,md5,sha1,sha256,sha384,sha512

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp