Decryption of string in VB.Net

'This class is responsible for decripting valuable data
'Call this method with parameters your data and key "NAPENCPT"


Public Class Encryption

'Decrypts data

Public Shared Function Decrypt(ByVal text As String, ByVal key As String) As String

Dim ms As MemoryStream = New MemoryStream

Try
Dim encodedkey() As Byte
Dim iv() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}

Dim bytes() As Byte

encodedkey = Encoding.UTF8.GetBytes(key)

Dim csp As DESCryptoServiceProvider = New DESCryptoServiceProvider

bytes = Convert.FromBase64String(text)

Dim cs As CryptoStream = New CryptoStream(ms, csp.CreateDecryptor(encodedkey, iv), CryptoStreamMode.Write)

cs.Write(bytes, 0, bytes.Length)
cs.FlushFinalBlock()

Catch ex As Exception
Return String.Empty
End Try

Return Encoding.UTF8.GetString(ms.ToArray)

End Function

End Class


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: