need help in converting these codes to vb.net

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
hi,

can anyone help me convert this code to vb.net?

VB.NET:
private string GenerateSalt() {
 byte[] buf = new byte[SALT_SIZE_IN_BYTES];
 (new RNGCryptoServiceProvider()).GetBytes(buf);
 return Convert.ToBase64String(buf);
}
i tried using conversion tools but gives me an error on the syntax.

VB.NET:
Private Function GenerateSalt() As String
    Dim buf As Byte() = New Byte(SALT_SIZE_IN_BYTES - 1) {}
    [I](New RNGCryptoServiceProvider()).GetBytes(buf)[/I]
    Return Convert.ToBase64String(buf)
End Function

thanks.
 
RNGCryptoServiceProvider belongs to System.Security.Cryptography namespace, so you can import this namespace or qualify the objects:
VB.NET:
Private Function GenerateSalt(ByVal SALT_SIZE_IN_BYTES As Integer) As String
    Dim buf(SALT_SIZE_IN_BYTES - 1) As Byte
    Security.Cryptography.RNGCryptoServiceProvider.Create.GetBytes(buf)
    Return Convert.ToBase64String(buf)
End Function
 
thanks! :)
 
Back
Top