ho scritto questa classe basandomi su MSDN e su quanto sono riuscito a trovare su internet:

---------------------------------------------------------
Imports System
Imports System.Text
Imports System.Security.Cryptography

Public Class DESEncrypterDecrypter

Dim DES As DESCryptoServiceProvider
Dim Transformer As ICryptoTransform
Dim res As Byte()
Dim encBytes As Byte()
Dim decBytes As Byte()

Public Sub New()

DES = New DESCryptoServiceProvider(ByVal key AS Byte())
DES.Key = key
DES.Mode = CipherMode.ECB

End Sub


Public Function Encrypt(ByVal strClare As String) As String
Try

decBytes = Encoding.ASCII.GetBytes(strClare)
Transformer = DES.CreateEncryptor()
encBytes = Transformer.TransformFinalBlock(decBytes, 0, decBytes.Length)

Return Convert.ToBase64String(encBytes)

Catch
MsgBox("Impossibile criptare la stringa: " & strClare, MsgBoxStyle.Exclamation, "ERRORE")
End Try
End Function


Public Function Decrypt(ByVal strEncoded As String) As String
Dim lun As Integer

Try

encBytes = Encoding.ASCII.GetBytes(strEncoded)
Transformer = DES.CreateDecryptor()
decBytes = Transformer.TransformFinalBlock(encBytes, 0, encBytes.Length)

Return Convert.ToBase64String(decBytes)

Catch e As Exception
MsgBox("Impossibile decriptare la stringa: " & e.Message, MsgBoxStyle.Exclamation, "ERRORE")
End Try
End Function
End Class

----------------------------------------------------

ora, il metodo per criptare mi funziona bene, ma quando uso il metodo per decriptare, arrivato all'istruzione

decBytes = Transformer.TransformFinalBlock(encBytes, 0, encBytes.Length)

mi da errore (Dati non validi)!
mi sapete consigliare la correzione da fare?