Giter Site home page Giter Site logo

asn1pkcs's Introduction

Asn1PKCS

PKCS #1/PKCS #8 RSA key ASN.1 encoder/decoder for C#.

Requirements

  • .NET Standard 1.3

Installing via NuGet

PM> Install-Package Nyamikan.Asn1PKCS

Usage

string derBase64EncodedString = "MEgCQQDOncyWnMXJmnkc5bqmRv5+x/KKes5uBHkoi1rywCLg4YJ1d+BvXSJbQ+bQdEWcporNeYo8hYLIQHZUz1SLiZKZAgMBAAE=";

RSAParameters rsaParameters = PKCS1DERDecoder.DecodePublicKey(derBase64EncodedString);
// rsaParameters.Modulus: byte[] { 0xCE, 0x9D, 0xCC, 0x96, 0x9C, 0xC5, 0xC9, 0x9A, 0x79, 0x1C, 0xE5, 0xBA, 0xA6, 0x46, 0xFE, 0x7E, 0xC7, 0xF2, 0x8A, 0x7A, 0xCE, 0x6E, 0x04, 0x79, 0x28, 0x8B, 0x5A, 0xF2, 0xC0, 0x22, 0xE0, 0xE1, 0x82, 0x75, 0x77, 0xE0, 0x6F, 0x5D, 0x22, 0x5B, 0x43, 0xE6, 0xD0, 0x74, 0x45, 0x9C, 0xA6, 0x8A, 0xCD, 0x79, 0x8A, 0x3C, 0x85, 0x82, 0xC8, 0x40, 0x76, 0x54, 0xCF, 0x54, 0x8B, 0x89, 0x92, 0x99 }
// rsaParameters.Exponent: byte[] { 0x01, 0x00, 0x01 }
RSAParameters rsaParameters = new RSAParameters();
rsaParameters.Modulus = new byte[] { 0xBE, 0x7D, 0xF2, 0xE9, 0x01, 0xCA, 0x41, 0x62, 0x6F, 0x1B, 0x88, 0x8A, 0xB9, 0x65, 0x95, 0x16, 0x25, 0x69, 0xDF, 0xC9, 0xB2, 0x48, 0x3D, 0x96, 0x65, 0x75, 0x13, 0x4D, 0x70, 0x52, 0x19, 0xF0, 0x52, 0xEC, 0xF4, 0x6E, 0xDA, 0x02, 0x76, 0x2C, 0x08, 0xB5, 0xB3, 0x8F, 0x5D, 0x76, 0x99, 0x1D };
rsaParameters.Exponent = new byte[] { 0x11 };

string derBase64EncodedString = PKCS8DEREncoder.EncodePublicKeyToBase64(rsaParameters);
// derBase64EncodedString: "MEowDQYJKoZIhvcNAQEBBQADOQAwNgIxAL598ukBykFibxuIirlllRYlad/Jskg9lmV1E01wUhnwUuz0btoCdiwItbOPXXaZHQIBEQ=="

License

MIT

asn1pkcs's People

Contributors

typewriter avatar

Watchers

James Cloos avatar Hassan Najm 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.