May 2020
Intermediate to advanced
1099 pages
27h 13m
English
In this chapter, we discuss the major cryptography APIs in .NET Core:
Windows Data Protection (DPAPI)
Hashing
Symmetric encryption
Public key encryption and signing
The types covered in this chapter are defined in the following namespaces:
System.Security; System.Security.Cryptography;
Table 21-1 summarizes the cryptography options in .NET. In the remaining sections, we explore each of these.
| Option | Keys to manage | Speed | Strength | Notes |
|---|---|---|---|---|
File.Encrypt |
0 | Fast | Depends on user’s password | Protects files transparently with filesystem support. A key is derived implicitly from the logged-in user’s credentials. Windows only. |
| Windows Data Protection | 0 | Fast | Depends on user’s password | Encrypts and decrypts byte arrays using an implicitly derived key. |
| Hashing | 0 | Fast | High | One-way (irreversible) transformation. Used for storing passwords, comparing files, and checking for data corruption. |
| Symmetric Encryption | 1 | Fast | High | For general-purpose encryption/decryption. The same key encrypts and decrypts. Can be used to secure messages in transit. |
| Public Key Encryption | 2 | Slow | High | Encryption and decryption use different keys. Used for exchanging a symmetric key in message transmission and for digitally signing files. |
.NET Core also provides more specialized support for creating and validating XML-based signatures in System.Security.Cryptography.Xml and types for working with digital certificates ...
Read now
Unlock full access