I am trying to encrypt/decrypt a string using c#. I’ve found countless tutorials on how to this ex: this However most of them assume you already have the key. So my question is:
How do I generate the key ?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using the encryption classes in the
System.Security.Cryptographynamespace, use theRfc2898DeriveBytesclass (@CodeInChaos points out that it supersedesPasswordDeriveBytes) to derive a key from a password.If a random key is OK, the
SymmetricAlgorithmclass has aGenerateKeymethod.