Clase de conexión
Enviado por Arielvelasquez • 4 de Marzo de 2018 • Tutorial • 587 Palabras (3 Páginas) • 156 Visitas
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security.Cryptography
Public Class Clase_conexion
Public Shared conn As New SqlClient.SqlConnection
Public Shared Function conectar(ByVal x As String, ByVal y As String) As Boolean
Dim String_Conection As String = ("server=" & x & ";INITIAL catalog=" & y & ";Integrated security=true")
Try
conn.ConnectionString = String_Conection
If conn.State = ConnectionState.Open Then
conectar = True
Else
conn.Open()
conectar = True
End If
Catch ex As Exception
conectar = False
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error al conectar a la BD")
End Try
End Function
Public Shared Sub Abrir_BD()
If conn.State = ConnectionState.Open Then
Else
conn.Open()
End If
End Sub
Public Shared Sub Cerrar_BD()
If conn.State = ConnectionState.Closed Then
Else
conn.Close()
End If
End Sub
End Class
Imports System.Text
Imports System.Security.Cryptography
Public Class Class_Password
Public Shared Function Encriptar(ByVal Input As String) As String
Dim IV() As Byte = ASCIIEncoding.ASCII.GetBytes("qualityi") 'La clave debe ser de 8 caracteres
Dim EncryptionKey() As Byte = Convert.FromBase64String("rpaSPvIvVLlrcmtzPU9/c67Gkj7yL1S5") 'No se puede alterar la cantidad de caracteres pero si la clave
Dim buffer() As Byte = Encoding.UTF8.GetBytes(Input)
...