TipsTrikSmall

Kumpulan Tips dan Trick Belajar Komputer

TipsTrikSmall Headline Animator

Translate

English French German Spain Italian Dutch Russian Portuguese Japanese Korean Arabic Chinese Simplified

Membuat program encrypt decrypt

Diposting oleh SvGie

buat 3 textbox dan 2 comand button
buat module



list form

Option Explicit

Private Sub Command1_Click()
Text2 = EncryptText(Text1, "gila")
End Sub

Private Sub Command2_Click()
Text3 = DecryptText(Text2, "gila")
End Sub

Private Sub Command3_Click()
Unload Me

End Sub

list module

Option Explicit

#Const CASE_SENSITIVE_PASSWORD = False

'Encrypt text
Public Function EncryptText(strText As String, ByVal strPwd As String) As String
Dim i As Integer, c As Integer
Dim strBuff As String

#If Not CASE_SENSITIVE_PASSWORD Then

'Convert password to upper case
'if not case-sensitive
strPwd = UCase$(strPwd)

#End If

'Encrypt string
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
EncryptText = strBuff
End Function

Public Function DecryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String

#If Not CASE_SENSITIVE_PASSWORD Then

'Convert password to upper case
'if not case-sensitive
strPwd = UCase$(strPwd)

#End If

'Decrypt string
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
DecryptText = strBuff
End Function

0 komentar:

Posting Komentar

print this page

Entri Top