Aes algorithem in C# [英] Aes algorithem in C#

查看:76
本文介绍了Aes algorithem in C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法制作了一个简单的程序,使用aes算法加密和解密c#中的文本,但我有几个问题:

1)什么是最好的类和使用aes的方法?因为我得到了这些课程:AesManaged,RijndaelManaged,AesCryptoServiceProvider。

2)我知道有一个密钥大小但我不能输入任何其他字符串而不是一个有8个字符的字符串。那怎么办?

3)为什么使用字符串作为关键是不安全的?

我的代码: [C#] aes - Pastebin.com [ ^ ] < br $>
求助!!!



我尝试过:



在google中搜索关于键的所有内容以及所有

i managed to make a simple program that encrypt and decrypt a text in c# using the aes algorithm but i have a few questions:
1) what is the best class and way to use the aes? cause i got those classes:AesManaged , RijndaelManaged , AesCryptoServiceProvider.
2) i understand there is a key size but i cant enter any other string rather than one that have 8 chars. so what to do?
3) why to use a string as a key isnt safe?
my code: [C#] aes - Pastebin.com[^]
ty for help!!!

What I have tried:

search tons in google about keys and all of that

推荐答案

这都是错的。一个键以某种方式与某些字符串相关的事实只不过是你的幻想。如果你从字符串生成一个键,那就是你的问题。所有加密密钥都只是字节数组。 (请参阅 Aes Class(System.Security。密码学) [ ^ ]。)此外,您应该了解这些密钥与密码的概念无关。



而且,以防万一:如果您认为密码(我现在谈论的是真正的密码)可以加密和存储,请再想一想:这个想法完全不安全。密码不应存储在任何地方或通过网络传输进行身份验证。如果您感到困惑或不同意,请阅读加密功能以及它们用于基于密码的身份验证。
我不知道您的目的是什么,这很糟糕。这是你必须解释的第一件事。对于大多数应用来说,对称加密的整个想法是值得怀疑的。您首先需要了解一些基本的加密思想。请参阅:

对称密钥算法 - 维基百科,免费百科全书 [ ^ ],

公共密钥加密 - 维基百科,免费的百科全书 [ ^ ],

密码学 - 维基百科,免费的百科全书 [ ^ ] 。



-SA
It's all wrong. The "fact" that a key is somehow related to some strings is nothing but your fantasy. If you generated a key from a string, it's your problem. All cryptographic keys are just arrays of bytes. (Please see Aes Class (System.Security.Cryptography)[^].) Also, you should understand that those keys have nothing to do with the concept of "password".

And, just in case: if you think that a password (I'm talking about real passwords now) can be encrypted and stored, think again: the idea would be totally unsafe. Passwords should never be stored anywhere or transmitted via the network for authentication. If you feel confused or disagree, read about cryptographic has functions and their use for password-based authentication.
I have no idea what is your purpose, and this is bad. This is the fist thing you had to explain. The whole idea of symmetric encryption is questionable for most applications. You need to understand some basic cryptographic ideas first. Please see:
Symmetric-key algorithm — Wikipedia, the free encyclopedia[^],
Public-key cryptography — Wikipedia, the free encyclopedia[^],
Cryptography — Wikipedia, the free encyclopedia[^].

—SA


这篇关于Aes algorithem in C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆