Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

equivalent vb code for a java code

Tags:

java

random

vba

Can anyone tell me what exactly does this Java code do?

SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
byte[] bytes = new byte[20];
synchronized (random)
{
    random.nextBytes(bytes);
}

return Base64.encode(bytes);

Step by step explanation will be useful so that I can recreate this code in VB. Thanks

like image 624
Shoban Avatar asked Dec 31 '22 11:12

Shoban


1 Answers

Using code snippets you can get to something like this

Dim randomNumGen As RandomNumberGenerator = RNGCryptoServiceProvider.Create()
Dim randomBytes(20) As Byte
randomNumGen.GetBytes(randomBytes)
return Convert.ToBase64String(randomBytes)
like image 106
Eduardo Campañó Avatar answered Jan 02 '23 00:01

Eduardo Campañó