Skip to content

Update rfc28981.cs example #9545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ public static void Main(string[] passwordargs)
//<SNIPPET6>
string pwd1 = passwordargs[0];
// Create a byte array to hold the random value.
byte[] salt1 = new byte[8];
using (RNGCryptoServiceProvider rngCsp = new
RNGCryptoServiceProvider())
{
// Fill the array with a random value.
rngCsp.GetBytes(salt1);
}
byte[] salt1 = RandomNumberGenerator.GetBytes(8);

//data1 can be a string or contents of a file.
string data1 = "Some test data";
Expand All @@ -43,9 +37,8 @@ public static void Main(string[] passwordargs)
try
{
//<SNIPPET4>
Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(pwd1, salt1,
myIterations);
Rfc2898DeriveBytes k2 = new Rfc2898DeriveBytes(pwd1, salt1);
Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(pwd1, salt1, myIterations, HashAlgorithmName.SHA256);
Rfc2898DeriveBytes k2 = new Rfc2898DeriveBytes(pwd1, salt1, myIterations, HashAlgorithmName.SHA256);
//</SNIPPET4>
// Encrypt the data.
Aes encAlg = Aes.Create();
Expand Down Expand Up @@ -98,4 +91,4 @@ public static void Main(string[] passwordargs)
}
}
}
//</SNIPPET1>
//</SNIPPET1>