For more information about the relevant namespace, see import it by yourself.
Public Shared Function desencrypt () Function Desencrypt ( Byval Strinput As String ) As String
Dim Objdescrypsrvprvd As Descryptoserviceprovider
Dim Objmemorystream As Memorystream = Nothing
Dim Objcryptostream As Cryptostream = Nothing
Dim Bytekey () As Byte = Text. encoding. ASCII. getbytes (mstrkey)
Dim Bytedata () As Byte = Text. encoding. ASCII. getbytes (strinput)
Try
Objdescrypsrvprvd = New Descryptoserviceprovider
Objmemorystream = New Memorystream
Objcryptostream = New Cryptostream (objmemorystream, objdescrypsrvprvd. createencryptor (bytekey, bytekey), cryptostreammode. Write)
Objcryptostream. Write (bytedata, 0 , Bytedata. length)
Objcryptostream. flushfinalblock ()
Return Convert. tobase64string (objmemorystream. toarray)
Catch Ex As Exception
Throw New Exception ( " Ehr. ehrdatabase. desdecrypt: " & Ex. Message, ex)
Finally
Objmemorystream. Dispose ()
Objcryptostream. Dispose ()
Objdescrypsrvprvd = Nothing
End Try
End Function
Public Shared Function desdecrypt () Function Desdecrypt ( Byval Strinput As String ) As String
Dim Objdescrypsrvprvd As Descryptoserviceprovider
Dim Objmemorystream As Memorystream = Nothing
Dim Objcryptostream As Cryptostream = Nothing
Dim Objencoding As Text. Encoding
Dim Bytekey () As Byte = Text. encoding. ASCII. getbytes (mstrkey)
Dim Bytedata () As Byte = Convert. frombase64string (strinput)
Try
Objdescrypsrvprvd = New Descryptoserviceprovider
Objmemorystream = New Memorystream
Objencoding = New Asciiencoding
Objcryptostream = New Cryptostream (objmemorystream, objdescrypsrvprvd. createdecryptor (bytekey, bytekey), cryptostreammode. Write)
Objcryptostream. Write (bytedata, 0 , Bytedata. length)
Objcryptostream. flushfinalblock ()
Return Objencoding. getstring (objmemorystream. toarray)
Catch Ex As Exception
Throw New Exception ( " Ehr. ehrdatabase. desencrypt: " & Ex. Message, ex)
Finally
Objmemorystream. Dispose ()
Objcryptostream. Dispose ()
Objdescrypsrvprvd = Nothing
End Try
end function