Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended .NET encryption library [closed]

Tags:

After reading (yet another) post by Jeff Atwood more or less concluding that us mortal developers shouldn't be getting too involved with encryption, I'm left wondering what library I should be using. The only two libraries I've found that seem legitimate are entlib's and Bouncy Castle, but they don't seem much more of an abstraction than the .NET cryptography APIs to me.

I guess what I'm wondering is if there is a "jQuery of cryptography libraries" that is simple, widely-trusted, open and well-documented.

like image 918
JeremyWeir Avatar asked Jul 24 '09 21:07

JeremyWeir


People also ask

How use RSA encryption in C#?

Create an RSA public/private keypair. Transmit the public key (or for proof of concept, just move it in a string variable) Create a new RSA crypto provider and encrypt a string with the public key. Transmit the encrypted string (or data) back to the original crypto provider and decrypt the string.

What is Tinycrypt?

tinycrypt is a library of cryptographic algorithms with a focus on small, simple implementation.

What is a shared cryptographic library that can be used for implementing cryptographic functionalities in projects?

Hyperledger Ursa is a shared cryptographic library that enables people (and projects) to avoid duplicating other cryptographic work and hopefully increase security in the process. The library is an opt-in repository for Hyperledger projects (and, potentially others) to place and use crypto.


2 Answers

edit: Here is a comprehensive list of popular crypto libraries from https://github.com/quozd/awesome-dotnet/blob/master/README.md#cryptography:

  • BouncyCastle - Together with the .Net System.Security.Cryptography, the reference implementation for cryptographic algorithms on the CLR.
  • HashLib - HashLib is a collection of nearly all hash algorithms you've ever seen, it supports almost everything and is very easy to use
  • libsodium-net - libsodium for .NET - A secure cryptographic library
  • Pkcs11Interop - Managed .NET wrapper for unmanaged PKCS#11 libraries that provide access to the cryptographic hardware
  • StreamCryptor - Stream encryption & decryption with libsodium and protobuf
  • SecurityDriven.Inferno - .NET crypto library. Professionally audited.

Original answer follows.


The Bouncy Castle library is indeed a well respected, and mature encryption library, but what's wrong with using many of the fantastic encryption functions that are built right into the .NET framework?

System.Security.Cryptography Namespace

In my experience, these implementations are rock-solid, provide numerous options (for example: you've usually got a Crypto API, CNG and Managed implementations of each algorithm to choose from) , and you're not going to "get it wrong", since you're only using the implementation. If you're slightly worried that you might use them incorrectly, you can always follow MSDN's own example code.

like image 147
CraigTP Avatar answered Jan 23 '23 18:01

CraigTP


You have completely misunderstood the maxim "do not implement encryption routines yourself". What this means is: do not roll your own RSA/DSA/whatever encryption algorithm. It doesn't mean that you shouldn't use one written by someone who knows what they are doing. In fact, if anything, adding more layers between you and the trusted algorithm is going to hurt you, and not the reverse.

like image 40
Jon Grant Avatar answered Jan 23 '23 19:01

Jon Grant