Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to create 256 bit AES symmetric key in c#?

What I have tried:

i have tried various method but its not working
Posted
Updated 15-Nov-16 1:30am

1 solution

Seriously, dude. Googling would have revealed this. If you don't know google, you're going to fail as a developer.

C#
private static readonly byte[] Salt = new byte[] { 10, 20, 30, 40, 50, 60, 70, 80 };

private static byte[] CreateKey(string password, int keyBytes = 32)
{
    const int Iterations = 300;
    var keyGenerator = new Rfc2898DeriveBytes(password, Salt, Iterations);
    return keyGenerator.GetBytes(keyBytes);
}
 
Share this answer
 
Comments
Nelek 15-Nov-16 7:34am    
Even googling... not sure about

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900