Sejak dulu, masalah sekuriti menjadi masalah yang sangat menarik dan menjadi perhatian bagi banyak orang khususnya orang2 IT. Berikut ini adalah contoh enkripsi yang dengan sedikit modifikasi bisa juga kita gunakan dalam Visual Basic. Sangat cocok untuk memproteksi dokumen-dokumen penting kita.

‘*************************************************

‘ Encrypt File Utility
‘ Copyright (C) 1995,1996 MagicTouch Software Inc.

‘*************************************************

ON ERROR GOTO error.trap
CLS
LOCATE 1, 1
PRINT
COLOR 10, 0
PRINT “Encrypt File Utility Release 1.1”
PRINT “Copyright (C) 1995 MagicTouch Software Inc. “
PRINT
COLOR 15, 0
INPUT “Enter File name : “, filespec$
IF filespec$ = “” THEN END
OPEN “R”, #1, filespec$, 1
FIELD #1, 1 AS f$
Norec = LOF(1)
IF Norec = 0 THEN
BEEP
COLOR 5, 0
PRINT “File Not Found… “
PRINT
CLOSE
COLOR 7, 0
END
END IF
OPEN “R”, #2, “ENCRYPT.DAT”, 1
FIELD #2, 1 AS g$
d$ = “”
x1 = 1: y1 = 1
GOSUB Unencrypt
enc$ = “Encrypting”
PRINT “File has not encrypted.”
INPUT “Encrypt File ? [Y/N] “, jwb$
IF jwb$ = “Y” OR jwb$ = “y” THEN
RSET g$ = “%”
PUT #2, y1
y1 = y1 + 1
GOTO Process
END IF
CLOSE
KILL “ENCRYPT.DAT”
END

Process:
WHILE x1 <= Norec
GET #1, x1
a = ASC(f$) XOR 12
d$ = CHR$(a)
RSET g$ = d$
PUT #2, y1
LOCATE 9, 1
PRINT enc$; y1; ” bytes”
x1 = x1 + 1
y1 = y1 + 1
WEND
CLOSE
KILL filespec$
NAME “ENCRYPT.DAT” AS filespec$
COLOR 14, 0
PRINT “Success… “
PRINT
FOR p = 1 TO 6
SOUND 5000, 1
SOUND 4000, 1
NEXT
FOR Delay = 1 TO 2000
NEXT
COLOR 7, 0
END

Unencrypt:
GET #1, 1
IF f$ = “%” THEN
PRINT “File already encrypted.”
INPUT “Unencrypt File ? [Y/N] “, jwb$
IF jwb$ = “Y” OR jwb$ = “y” THEN
x1 = x1 + 1
enc$ = “Unencrypting”
GOTO Process
END IF
CLOSE
KILL “ENCRYPT.DAT”
END
END IF
RETURN

error.trap:
DEF SEG
z% = ERDEV
e = PEEK(VARPTR(z%))
IF e = 2 THEN
PRINT “Drive not ready… Press any key to continue…”
a$ = INPUT$(1)
RUN
END IF
IF e = 0 THEN
PRINT “Write protected error… Press any key to continue…”
a$ = INPUT$(1)
RUN
END IF

2 Comments on Encryption

  1. sakri says:

    Mas ini program untuk membuat kode ya????//