|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form frmEncriptador
BorderStyle = 1 'Fixed Single
Caption = "Easy Encrypt"
ClientHeight = 4980
ClientLeft = 3585
ClientTop = 3150
ClientWidth = 8445
Icon = "frmEncriptador.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4980
ScaleWidth = 8445
Begin VB.Data dtaEncrypt
Caption = "Data1"
Connect = "Access"
DatabaseName = "bd_Encriptador.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 345
Left = 3600
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Encrypt"
Top = 1920
Visible = 0 'False
Width = 1215
End
Begin VB.TextBox txtEncriptado
Height = 4215
Left = 4440
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 1
Top = 480
Width = 3735
End
Begin VB.TextBox txtNormal
Height = 4215
Left = 240
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 0
Top = 480
Width = 3735
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3480
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Label lblEncriptado
Caption = "Texto Encriptado:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4440
TabIndex = 3
Top = 120
Width = 1935
End
Begin VB.Label lblNormal
Caption = "Texto Normal:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 2
Top = 120
Width = 1815
End
Begin VB.Menu Ficheiro
Caption = "&Ficheiro"
Begin VB.Menu Abrir_Ficheiro
Caption = "Abrir Ficheiro"
Shortcut = ^O
End
Begin VB.Menu Sair
Caption = "Sair"
Shortcut = ^Q
End
End
Begin VB.Menu Encriptacao_Decriptacao
Caption = "&Encripta??o/Decripta??o"
Begin VB.Menu Encriptacao
Caption = "Encripta??o"
Begin VB.Menu Encriptar
Caption = "Encriptar"
Shortcut = ^E
End
Begin VB.Menu GuardarEncriptacao
Caption = "Guardar Encripta??o"
Shortcut = ^S
End
End
Begin VB.Menu Decriptacao
Caption = "Decripta??o"
Begin VB.Menu AbrirFicheiro
Caption = "Abrir Ficheiro"
Shortcut = ^A
End
Begin VB.Menu Decriptar1
Caption = "Decriptar"
Shortcut = ^D
End
Begin VB.Menu SalvarDecriptacao
Caption = "Salvar Decripta??o"
Shortcut = ^G
End
End
End
Begin VB.Menu Ajuda
Caption = "Ajuda"
Begin VB.Menu Sobre
Caption = "Sobre"
Shortcut = {F12}
End
End
End
Attribute VB_Name = "frmEncriptador"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strTmp As String
Dim strX As String
Dim strDepois As String
Dim strAntes As String
Dim strPass As String
Dim intPass As Integer
Dim lngContador As Long
Dim intP As Integer
Dim Valida As Boolean
Dim FileName As String
Dim p As Integer
Dim strName As String
Dim lngR As Long
Private Sub Abrir_Ficheiro_Click()
txtNormal = ""
strTmp = ""
strX = "Text Files (*.txt)|*.txt"
strX = strX & "|All files (*.*)"
strX = strX & "|*.*"
CommonDialog1.Filter = strX
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Input As #1
While Not EOF(1)
Line Input #1, strTmp
txtNormal = txtNormal + strTmp + vbNewLine
Wend
Close #1
End If
End Sub
Private Sub AbrirFicheiro_Click()
txtNormal.Text = ""
txtEncriptado.Text = ""
strTmp = ""
strX = "Text Files (*.txt)|*.txt"
strX = strX & "|All files (*.*)"
strX = strX & "|*.*"
CommonDialog1.Filter = strX
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
p = InStrRev(FileName, "\")
strName = Right(FileName, Len(FileName) - p)
If FileName <> "" Then
dtaEncrypt.Recordset.MoveFirst
While Not dtaEncrypt.Recordset.EOF
If dtaEncrypt.Recordset.Fields("Nome") = strName Then
strPass = InputBox("Insira a password.", "Easy Encrypt")
If strPass <> "" Then
If dtaEncrypt.Recordset.Fields("Password") = strPass Then
intPass = dtaEncrypt.Recordset.Fields("Encrypt_Num")
Open FileName For Input As #1
While Not EOF(1)
Line Input #1, strTmp
txtEncriptado = txtEncriptado + strTmp + vbNewLine
Wend
Else
MsgBox "Password Errada!", vbCritical, "Easy Encrypt"
Exit Sub
End If
End If
End If
dtaEncrypt.Recordset.MoveNext
Wend
End If
Close #1
End Sub
Private Sub Decriptar1_Click()
If txtEncriptado.Text = "" Then
MsgBox "N?o existe texto para decriptar!", vbCritical, "Easy Encrypt"
Else
strDepois = ""
strAntes = ""
lngR = Len(txtEncriptado)
For lngContador = 1 To lngR
strAntes = Mid(txtEncriptado, lngContador, 1)
intP = Asc(strAntes) + intPass
strDepois = strDepois & Chr(intP)
txtNormal = strDepois
Next lngContador
End If
End Sub
Private Sub Encriptar_Click()
If txtNormal.Text = "" Then
MsgBox "N?o existe texto para encriptar!", vbCritical, "Easy Encrypt"
Else
txtEncriptado = ""
strDepois = ""
strAntes = ""
strPass = InputBox("Insira a password.", "Easy Encrypt")
If strPass <> "" Then
intPass = Pass()
For lngContador = 1 To Len(txtNormal)
strAntes = Mid(txtNormal, lngContador, 1)
intP = Asc(strAntes) - intPass
strDepois = strDepois & Chr(intP)
Next lngContador
txtEncriptado = strDepois
End If
End If
End Sub
Private Sub Sair_Click()
End
End Sub
Private Sub SalvarDecriptacao_Click()
If txtNormal.Text = "" Then
MsgBox "N?o existe texto decriptar para guardar!", vbCritical, "Easy Encrypt"
Else
strX = "Text Files (*.txt)|*.txt"
strX = strX & "|All files (*.*)"
strX = strX & "|*.*"
CommonDialog1.Filter = strX
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
FileName = CommonDialog1.FileName
Open CommonDialog1.FileName For Output As #1
Print #1, txtNormal.Text
Close #1
txtEncriptado.Text = ""
txtNormal.Text = ""
End If
End If
End Sub
Private Sub GuardarEncriptacao_Click()
If txtEncriptado.Text = "" Then
MsgBox "N?o existe texto encriptado para gravar!", vbCritical, "Easy Encrypt"
Else
Valida = False
strX = "Text Files (*.txt)|*.txt"
strX = strX & "|All files (*.*)"
strX = strX & "|*.*"
CommonDialog1.Filter = strX
CommonDialog1.ShowSave
FileName = CommonDialog1.FileName
p = InStrRev(FileName, "\")
strName = Right(FileName, Len(FileName) - p)
While Not dtaEncrypt.Recordset.EOF
If dtaEncrypt.Recordset.Fields("Nome") = strName Then
Valida = True
End If
dtaEncrypt.Recordset.MoveNext
Wend
If Valida = True Then
MsgBox "Por favor altere o nome do ficheiro que deseja gravar.", vbExclamation, "Easy Encrypt"
Else
dtaEncrypt.Recordset.AddNew
dtaEncrypt.Recordset.Fields("Password") = strPass
dtaEncrypt.Recordset.Fields("Nome") = strName
dtaEncrypt.Recordset.Fields("Encrypt_Num") = intPass
dtaEncrypt.Recordset.Update
Open FileName For Output As #1
Print #1, txtEncriptado.Text
Close #1
txtEncriptado.Text = ""
txtNormal.Text = ""
End If
End If
End Sub
Function Pass() As Integer
Dim intL As Integer
Dim intR As Integer
Dim intContador1 As Integer
Dim intContador2 As Integer
Dim intSoma1 As Integer
Dim intSoma2 As Integer
Dim intSoma3 As Integer
Dim strL As String
Dim strR As String
intL = Asc(Left(strPass, 1))
intR = Asc(Right(strPass, 1))
strL = CStr(intL)
strR = CStr(intR)
For intContador1 = 1 To Len(strL)
intSoma1 = intSoma1 + Mid(strL, intContador1, 1)
Next intContador1
For intContador2 = 1 To Len(strR)
intSoma2 = intSoma2 + Mid(strR, intContador2, 1)
Next intContador2
intSoma3 = intSoma1 + intSoma2
If intSoma3 >= 1 And intSoma3 <= 10 Then
Pass = Fix(intSoma3 / 2)
ElseIf intSoma3 > 10 And intSoma3 <= 20 Then
Pass = Fix(intSoma3 / 3)
ElseIf intSoma3 > 20 And intSoma3 <= 30 Then
Pass = Fix(intSoma3 / 4)
ElseIf intSoma3 > 30 And intSoma3 <= 40 Then
Pass = Fix(intSoma3 / 5)
End If
End Function
Private Sub Sobre_Click()
frmSobre.Show
End Sub
|