Results 1 to 4 of 4

Thread: C# convert multi bytes to VB.NET

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2017
    Posts
    199

    C# convert multi bytes to VB.NET

    Hello can someone help me how i can convert this line: (byte[] salt, byte[] verifier) = GetSRP6RegistrationData(username,password);

    Code:
    public static void Main(string[] args)
    {
    string username = "test";
    string password = "passwor";
    
     (byte[] salt, byte[] verifier) = GetSRP6RegistrationData(username,password);
     
     using (var connection = new MySqlConnection("server=127.0.0.1;database=acore_auth;user=root;password=pass;"));
     {
     connection.Open();
     using (var command = new MySqlCommand("Insert Into account (username,salt,verifier) VALUES (@username, @salt, @verifier)". connection))
     {
     Command.Parameters.AddWithValue("@Username", username.ToUpper());
     Command.Parameters.AddWithValue("@Salt", salt);
     Command.Parameters.AddWithValue("@Verifier", verifier);
     command.ExecuteNonQuery();
     }
     }
     }
    and class
    Code:
    public static (byte[] Salt, byte[] Verifier) GetSRP6RegistrationData(string username,string password)
    {
    byte[] salt = new byte[32];
    var rng = RandomNumberGenerator.Create();
    rng.GetBytes(salt);
    rng.Dispose();
    
    byte[] verifier = CalculateSRP6Verifier(username,password,salt);
    
    return (salt,verifier);
    }
    class converted:
    Code:
    Public Shared Function GetSRP6RegistrationData(username As String, password As String) As (Salt As Byte(), Verifier As Byte())
            Dim salt As Byte() = New Byte(31) {}
            Dim rng = RandomNumberGenerator.Create()
            rng.GetBytes(salt)
            rng.Dispose()
            Dim verifier As Byte() = CalculateSRP6Verifier(username, password, salt)
            Return (salt, verifier)
        End Function
    Last edited by luckydead; Dec 14th, 2023 at 05:42 AM.

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
  •  



Click Here to Expand Forum to Full Width