thanks for the help. It looked like a promising solution but unfortunately did not solve my problem.
I'm trying to read a string from a text file so I can encrypt it.
When I create the text file manually, it reads and encrypts correctly.
If I try to create the text file dynamically, it encrypts to a slightly different outcome.
I can't understand why the difference.
<code>
Private Shared ReadOnly encryptionKeyBytes() As Byte = New Byte() {53, 53, 53, 53, 53, 53, 53, 53}
Private Shared Function GenerateEncryptedLicFile(ByVal inputText As String, ByVal outputFile As String) As Boolean
Dim outputStream As Stream = Nothing
Dim encryptedStream As Stream = Nothing
Dim result As Boolean = False
Dim des As DESCryptoServiceProvider = New DESCryptoServiceProvider()
des.Key = encryptionKeyBytes
des.IV = encryptionKeyBytes
Try
outputStream = New FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None)
Dim desEncryptor As ICryptoTransform = des.CreateEncryptor()
encryptedStream = New CryptoStream(outputStream, desEncryptor, CryptoStreamMode.Write)
Dim contents() As Byte = des.EncryptValue(inputText)
encryptedStream.Write(contents, 0, contents.Length)
result = True
Finally
If Not encryptedStream Is Nothing Then
encryptedStream.Close()
encryptedStream = Nothing
End If
If Not outputStream Is Nothing Then
outputStream.Close()
outputStream = Nothing
End If
End Try
Return result
End Function
</code>