I have the following code:
Public Shared Function Crypt(text As String) As String
If text <> "" Then
Dim cryptoProvider As New DESCryptoServiceProvider()
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), CryptoStreamMode.Write)
Dim sw As New StreamWriter(cs)
sw.Write(text)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
'convert back to a string
Return Convert.ToBase64String(ms.GetBuffer(), 0, CInt(ms.Length))
End If
Return ""
End Function
after a Fortify scan, they report that i need to release the cs CryptoStream object.
As far as i know, FlushFinalBlock() method do it this job.
Do I need call the disponse() function too? Or may be is a false-positive issue?