I'm having trouble converting the java code to VB.NET
SecretKeySpec skey = new SecretKeySpec(key, "DESede");
any idea ? Thanks :)
Public Function GenerateTripleDesKey() As Byte()
Dim rng As New RNGCryptoServiceProvider()
Dim tripleDesKey As Byte() = New Byte(23) {}
rng.GetBytes(tripleDesKey)
For i As Integer = 0 To tripleDesKey.Length - 1
Dim keyByte As Integer = tripleDesKey(i) And &HFE
Dim parity = 0
Dim b As Integer = keyByte
While b <> 0
parity = parity Xor b And 1
b >>= 1
End While
tripleDesKey(i) = CByte(keyByte Or (If(parity = 0, 1, 0)))
Next
Return tripleDesKey
End Function
Of course, getting this to work properly depends on how you translated the
SecretKeySpec
definition.