Problemas al desencriptar
Publicado por kryptic (40 intervenciones) el 05/09/2007 15:26:07
Kiubo espero se encuentren bien, bueno tengo el siguiente modulo:
Imports System.Security.Cryptography
Module Krypto
Private sec As New RSACryptoServiceProvider
Private bytString(), bytEncrypted(), bytDesencrypted() As Byte
Private ue As New System.Text.UTF8Encoding
Private Encrypted As String = ""
Private Desencrypted As String = ""
Private strEncryptedPassword As String = ""
Public Function Encriptar(ByVal EncriptString As String) As String
If EncriptString = "" Then
Return Nothing
Exit Function
End If
Try
bytString = ue.GetBytes(EncriptString)
bytEncrypted = sec.Encrypt(bytString, False)
Encrypted = Convert.ToBase64String(bytEncrypted)
Catch exc As Exception
MsgBox("Un error ha ocurrido en la encriptación.")
End Try
Return Encrypted
End Function
Public Function Desencriptar(ByVal TextEncripted As String) As String
If TextEncripted = "" Then
Return Nothing
Exit Function
End If
Try
bytDesencrypted = sec.Decrypt(Convert.FromBase64String(TextEncripted), False)
Desencrypted = ue.GetString(bytDesencrypted)
Catch exc As Exception
MsgBox("Un error ha ocurrido en la desencriptación.")
End Try
Return Desencrypted
End Function
End Module
Que lo propuso Harold aqui en el foro, el problema ke tengo es ke estoy guardando una contraseña encriptada por este medio en una base de datos, en un campo varchar(172) y al querer desencriptar me muestra el error "Datos incorrectos", que podra ser???
Imports System.Security.Cryptography
Module Krypto
Private sec As New RSACryptoServiceProvider
Private bytString(), bytEncrypted(), bytDesencrypted() As Byte
Private ue As New System.Text.UTF8Encoding
Private Encrypted As String = ""
Private Desencrypted As String = ""
Private strEncryptedPassword As String = ""
Public Function Encriptar(ByVal EncriptString As String) As String
If EncriptString = "" Then
Return Nothing
Exit Function
End If
Try
bytString = ue.GetBytes(EncriptString)
bytEncrypted = sec.Encrypt(bytString, False)
Encrypted = Convert.ToBase64String(bytEncrypted)
Catch exc As Exception
MsgBox("Un error ha ocurrido en la encriptación.")
End Try
Return Encrypted
End Function
Public Function Desencriptar(ByVal TextEncripted As String) As String
If TextEncripted = "" Then
Return Nothing
Exit Function
End If
Try
bytDesencrypted = sec.Decrypt(Convert.FromBase64String(TextEncripted), False)
Desencrypted = ue.GetString(bytDesencrypted)
Catch exc As Exception
MsgBox("Un error ha ocurrido en la desencriptación.")
End Try
Return Desencrypted
End Function
End Module
Que lo propuso Harold aqui en el foro, el problema ke tengo es ke estoy guardando una contraseña encriptada por este medio en una base de datos, en un campo varchar(172) y al querer desencriptar me muestra el error "Datos incorrectos", que podra ser???
Valora esta pregunta


0