如何加密/解密字符串?

发布于 2024-08-05 18:51:26 字数 144 浏览 1 评论 0原文

跟进这个问题,我想知道什么是RSA关键是,我将如何在 C# 中创建和使用它。

Following up on this question, I would like to know what an RSA key is, and how I would go about creating and using one in C#.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨夜星沙 2024-08-12 18:51:26

来自维基百科

在密码学中,RSA(代表首次公开描述它的 Rivest、Shamir 和 Adleman;见下文)是一种公钥密码学算法。它是已知的第一个适用于签名和加密的算法,也是公钥密码学领域最早的重大进步之一。 RSA 广泛应用于电子商务协议中,并且考虑到足够长的密钥和使用最新的实现,被认为是安全的。

您是否查看过 RSACryptoServiceProvider< /a> 类? .NET 使大多数应用程序都可以轻松实现这一点。

From Wikipedia:

In cryptography, RSA (which stands for Rivest, Shamir and Adleman who first publicly described it ; see below) is an algorithm for public-key cryptography. It is the first algorithm known to be suitable for signing as well as encryption, and one of the first great advances in public key cryptography. RSA is widely used in electronic commerce protocols, and is believed to be secure given sufficiently long keys and the use of up-to-date implementations.

Have you looked at the RSACryptoServiceProvider class? .NET makes this easy for most applications.

用心笑 2024-08-12 18:51:26

有两种加密方式:对称加密和非对称加密。

对称加密使用发送者和接收者之间共享的单个密钥。

非对称加密,也称为公钥加密,使用两个密钥(密钥对),其中一个(私钥)保密,另一个(密钥对)保密,另一个(密钥对) >公钥)可供其他人使用。发送者使用接收者的公钥来加密数据,接收者使用他的私钥来解密数据。

RSA 是一种非对称/公钥加密方案。

AES 是一种对称加密方案。

混合方案将两者结合起来,以便使用对称加密对数据进行加密,但使用非对称加密对加密密钥本身进行加密、存储和交换。

因此,您需要弄清楚打算如何管理加密密钥。如果您正在设计一个只需要加密内容(例如,SSN 或密码)以将其保存到数据库,然后在需要使用它们时解密的系统,那么对称加密是合适的。如果您打算跨不同系统传输加密信息,那么非对称(或混合)加密是合适的。

There are two kinds of encryption: symmetric and asymmetric.

Symmetric crypto uses a single key that is shared between the sender and the receiver.

Asymmetric crypto, a.k.a. public-key cryptography, uses two keys (a key pair), one of which (the private key) is kept secret and the other (the public key) is made available to everyone else. The sender uses the public key of the receiver to encrypt data, and the receiver uses his private key to decrypt it.

RSA is an asymmetric/public-key crypto scheme.

AES is a symmetric crypto scheme.

Hybrid schemes combine both, so that the data is encrypted using symmetric encryption, but the encryption keys themselves are encrypted, stored, and exchanged using asymmetric encryption.

So you need to figure out how you intend to manage the encryption keys. If you're designing a system that only needs to encrypt things (e.g., SSNs or passwords) to save them to a database and then later decrypt them when it needs to use them, then symmetric crypto is appropriate. If you're intending to transmit encrypted info across different systems, then asymmetric (or hybrid) crypto is appropriate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文