-
Jun 4th, 2012, 10:18 PM
#1
Thread Starter
Junior Member
[Help] Obsolete Code
Code:
' Use the password to generate key bytes.
Private Sub MakeKeyAndIV(ByVal password As String, ByVal key_size_bits As Integer, ByVal block_size_bits As Integer, ByRef key As Byte(), ByRef iv As Byte())
Dim password_derive_bytes As New PasswordDeriveBytes( _
password, Nothing, "SHA384", 1000)
key = password_derive_bytes.GetBytes(key_size_bits \ 8)
iv = password_derive_bytes.GetBytes(block_size_bits \ 8)
End Sub
Warning 1 'Public Overrides Function GetBytes(cb As Integer) As Byte()' is obsolete: 'Rfc2898DeriveBytes replaces PasswordDeriveBytes for deriving key material from a password and is preferred in new applications.'.
I have found the above code on generating passwords but when I converted the whole project it displays 2 warnings that the code was obsolete but when I search google I didnt found any fix for that warning.
-
Jun 4th, 2012, 11:37 PM
#2
Re: [Help] Obsolete Code
You don't need to search Google. The warning message itself tells you what to do:
Rfc2898DeriveBytes replaces PasswordDeriveBytes for deriving key material from a password and is preferred in new applications.
You should be using the Rfc2898DeriveBytes class rather than the PasswordDeriveBytes class. The documentation can show you the usage but, while I've neevr used either myself, I think the two are used in basically the same way and it's just that the new class has an internal implementation that satisfies the latest standards.
-
Jun 5th, 2012, 12:55 AM
#3
Thread Starter
Junior Member
Re: [Help] Obsolete Code
I am getting an error if I change PasswordDeriveByres to Rfc2898DeriveBytes...
vb Code:
Dim password_derive_bytes As New Rfc2898DeriveBytes(password, Nothing, "SHA384", 1000) key = password_derive_bytes.GetBytes(key_size_bits \ 8) iv = password_derive_bytes.GetBytes(block_size_bits \ 8)
no accessible 'New' accepts this number of arguments...
-
Jun 5th, 2012, 12:58 AM
#4
Re: [Help] Obsolete Code
So have a look at the MSDN documentation for the Rfc2898DeriveBytes class and see what parameters its constructors do have. You should also be reading the documentation to see how it works. Like I said, I've never actually used it so, while I can say that they are similar from what little I've seen, I can't say whether they are the same.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|