Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

I have done with RNGSERVICEPROVIDER, is it correct?

$
0
0
i have done following code to generate secure random number. is it correct and efficient and good enough??
  Public Sub secrand()
        Static r As Random = Nothing

        If r Is Nothing Then
            Dim seed() As Byte = New Byte(4) {}
            Dim rng As New RNGCryptoServiceProvider
            rng.GetBytes(seed)
            r = New Random(BitConverter.ToInt32(seed, 0))
            Label4.Text = r.Next(1000, 9999)
        End If
    End Sub


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>