Cara buatnya cukup mudah :
- Buat Project baru, dan tambahkan code berikut kedalam form atau modul anda
1: Function crypt(Action As String,Key As String, Src As String) As String
2: Dim Count As Integer, KeyPos As Integer, KeyLen As Integer
3: Dim SrcAsc As Integer, Dest As String, offset As Integer
4: Dim TmpSrcAsc, SrcPos
5: KeyLen = Len(Key)
6: If Action = "E" Then
7: Randomize
8: offset = (Rnd * 10000 Mod 255) + 1
9: Dest = Hex$(offset)
10: If Len(Dest) = 1 Then
11: Dest = "0" + Dest
12: End If
13: For SrcPos = 1 To Len(Src)
14: SrcAsc =(Asc(Mid$(Src, SrcPos, 1)) + offset) Mod 255
15: If KeyPos < style="color: rgb(0, 0, 255);">Then KeyPos = KeyPos + 1 Else KeyPos = 1
16: SrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
17: Dest = Dest + Format$(Hex$(SrcAsc), "@@")
18: offset = SrcAsc
19: Next
20: ElseIf Action = "D" Then
21: offset = Val("&H" + Left$(Src, 2))
22: For SrcPos = 3 To Len(Src) Step 2
23: SrcAsc = Val("&H"+ Trim(Mid$(Src, SrcPos, 2)))
24: If KeyPos < style="color: rgb(0, 0, 255);">Then
25: KeyPos= KeyPos + 1
26: Else
27: KeyPos= 1
28: End If
29: TmpSrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
30: If TmpSrcAsc <=offset Then
31: TmpSrcAsc = 255 + TmpSrcAsc - offset
32: Else
33: TmpSrcAsc = TmpSrcAsc - offset
34: End If
35: Dest = Dest +Chr(TmpSrcAsc)
36: offset = SrcAsc
37: Next
38: End If
39: crypt = Dest
40: End Function
Kemudian untuk mengencrypt suatu teks gunakan metode
Crypt(”E”,”TeksKunci”,”TeksyangdiEnkripsi”)
- Sedangkan untuk mengembalikan / decrypt lagi gunakan metode
Crypt(”D”,”TeksKunci”,”TeksyangdiDekripsi”)




Tidak ada komentar:
Posting Komentar