Not sure if this should be posted here or in SQL forum, but here goes:
I've used the following code in an ASP.net application to Encrypt a string...
The return from this function is then written to a SQL Server database. Then I use the reverse of this to decrypt the string in ASP.net. This all works just fine. However, I would also like to be able to decrypt this string via a stored procedure or SQL function, without having to use asp.net. Is this possible? If so, suggestions on how to get started?
mwa
<><
I've used the following code in an ASP.net application to Encrypt a string...
Code:
Public Shared Function Encryptor(ByVal strText As String, ByVal strEncrKey _
As String) As String
'will encrypt a string, in a way that can be decrypted
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Try
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey)
Dim des As New DESCryptoServiceProvider
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText)
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
Catch ex As Exception
Return ex.Message
End Try
End Function
The return from this function is then written to a SQL Server database. Then I use the reverse of this to decrypt the string in ASP.net. This all works just fine. However, I would also like to be able to decrypt this string via a stored procedure or SQL function, without having to use asp.net. Is this possible? If so, suggestions on how to get started?
mwa
<><