ArticleDirectory
- 1, base64
- 2. Des and RSA
- 3. sha1 and MD5
1, base64
Scenario: You want to express a set of binary data as a group of visible characters, which is more conducive to transmission in some cases, such as transmission in emails.
Algorithm: Http://zh.wikipedia.org/wiki/Base64
2. Des and RSA
Scenario: You want to encrypt a set of binary data. For example, if you want to protect your data from being stolen by others, even if they have your encrypted binary data, they still cannot be unlocked without a password.
Algorithm:
Des: http://zh.wikipedia.org/wiki/DES
RSA: http://zh.wikipedia.org/wiki/RSA%E5%8A%A0%E5%AF%86%E6%BC%94%E7% AE %97%E6%B3%95
Differences: Des is symmetric encryption, that is, encryption and decryption use the same key. RSA uses asymmetric encryption, Public Key for encryption, and private key for decryption.
Discussion:
Des can be cracked by brute force attacks. AES is generally used to replace DES encryption.
Because RSA is non-symmetric encryption, you can use the private key to encrypt it and decrypt it with the unique public key. However, this is not the way public encryption works. For details, see:
Http://stackoverflow.com/questions/1181421/is-possible-to-encrypt-with-private-key-using-net-rsacryptoserviceprovider
The real encryption method with the private key is digital signature. That is, you sign a binary stream with a private key. The receiver uses the public key to verify your signature. In this way, you can know the authenticity of the source and anti-repudiation. The specific C # instance can refer to: https://gist.github.com/3991414
3. sha1 and MD5
Scenario: You have a set of binary data. To ensure the integrity of this set of binary data, you want to generate a unique digital signature for this set of binary data.
Algorithm:
Sha1: http://zh.wikipedia.org/wiki/SHA1
MD5: http://zh.wikipedia.org/wiki/MD5