Giter Club home page Giter Club logo

rsautil's Introduction

RSAUtil 中文文档

.NET Core RSA algorithm using the help tool.It supports data encryption, decryption, signature and verification signature.It supports three key formats, namely: xml, pkcs1, pkcs8.It also supports key conversion for these three formats.Last also support pem formatting.

Thanks for onovotny's bc-csharp

Latest version

Install

Install-Package XC.RSAUtil

The old package name is XC.Framework.Security.RSAUtil. Now renamed XC.RSAUtil and will continue to use.

Doc

Generate the key

Use class RsaKeyGenerator.The result returned is a list of two-element strings,Element 1 is the private key and element 2 is the public key.

Format: XML

var keyList = RsaKeyGenerator.XmlKey(2048);
var privateKey = keyList[0];
var publicKey = keyList[1];

Format: Pkcs1

var keyList = RsaKeyGenerator.Pkcs1Key(2048);
var privateKey = keyList[0];
var publicKey = keyList[1];

Format: Pkcs8

var keyList = RsaKeyGenerator.Pkcs8Key(2048);
var privateKey = keyList[0];
var publicKey = keyList[1];

RSA key conversion

Use class RsaKeyConvert.It supports key conversion for these three formats,namely: xml, pkcs1, pkcs8.

XML->Pkcs1:
  • Private Key : RsaKeyConvert.PrivateKeyXmlToPkcs1()
  • Public Key : RsaKeyConvert.PublicKeyXmlToPem()
XML->Pkcs8:
  • Private Key : RsaKeyConvert.PrivateKeyXmlToPkcs8()
  • Public Key : RsaKeyConvert.PublicKeyXmlToPem()
Pkcs1->XML:
  • Private Key : RsaKeyConvert.PrivateKeyPkcs1ToXml()
  • Public Key : RsaKeyConvert.PublicKeyPemToXml()
Pkcs1->Pkcs8:
  • Private Key : RsaKeyConvert.PrivateKeyPkcs1ToPkcs8()
  • Public Key : No conversion required
Pkcs8->XML:
  • Private Key : RsaKeyConvert.PrivateKeyPkcs8ToXml()
  • Public Key : RsaKeyConvert.PublicKeyPemToXml()
Pkcs8->Pkcs1:
  • Private Key : RsaKeyConvert.PrivateKeyPkcs8ToPkcs1()
  • Public Key : No conversion required

Encrypt, decrypt, sign, and verify signatures

XML, Pkcs1, Pkcs8 respectively corresponding categories: RsaXmlUtil, RsaPkcs1Util, RsaPkcs8Util.They inherit from the abstract class RSAUtilBase

  • Encrypt: RSAUtilBase.Encrypt()
  • Decrypt: RSAUtilBase.Decrypt()
  • Sign: RSAUtilBase.SignData()
  • Verify: RSAUtilBase.VerifyData()

PEM formatting

Use class RsaPemFormatHelper.

  • Format Pkcs1 format private key: RsaPemFormatHelper.Pkcs1PrivateKeyFormat()

  • Remove the Pkcs1 format private key format: RsaPemFormatHelper.Pkcs1PrivateKeyFormatRemove()

  • Format Pkcs8 format private key: RsaPemFormatHelper.Pkcs8PrivateKeyFormat()

  • Remove the Pkcs8 format private key format: RsaPemFormatHelper.Pkcs8PrivateKeyFormatRemove()

Reference component

bc-csharp - onovotny

Cases

dotnetrsa - DotnetRSA is a .NET Core Global Tool.Dotnet RSA Tool can help you generate xml pkcs1, pkcs8 three kinds of format keys, and supports three types of mutual conversion.

rsautil's People

Contributors

stulzq avatar daullmer avatar

Watchers

James Cloos avatar  avatar  avatar

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.