我有一个用VB编写的加密类,我试图将其转换为C#.在VB代码中,有一段代码:
' Allocate byte array to hold our salt.
Dim salt() As Byte = New Byte(saltLen - 1) {}
' Populate salt with cryptographically strong bytes.
Dim rng As RNGCryptoServiceProvider = New RNGCryptoServiceProvider()
rng.GetNonZeroBytes(salt)
' Split salt length (always one byte) into four two-bit pieces and
' store these pieces in the first four bytes of the salt array.
salt(0) = ((salt(0) And &HFC) Or (saltLen And &H3))
salt(1) = ((salt(1) And &HF3) Or (saltLen And &HC))
salt(2) = ((salt(2) …Run Code Online (Sandbox Code Playgroud)