Original Post
🔒 Locked
Visual Basic Question
Advertisement
Of course. You just need to write your own custom file format, language doesn't matter.
The simplest way of doing this would be to insert a boolean variable in a file; if it's true, it means password protected. When you read the file, check if this boolean is true. If so, pops out a dialogbox, ask for a password, then compare it to the password inside the file.
The simplest way of doing this would be to insert a boolean variable in a file; if it's true, it means password protected. When you read the file, check if this boolean is true. If so, pops out a dialogbox, ask for a password, then compare it to the password inside the file.
First ask for a password,
like,
inp = inputbox("What is the password?")
You then turn int into a number,
i = 1
for x = 1 to len(inp)
i = i * asc(mid(Inp, x, 1))
i = (i mod 256) + 1
next x
i = i - 1
You then open the file for binary as #1 and dump the contents into a byte-buffer
dim bytebuff() as byte
open filename for binary as #1
redim bytebuff(lof(1))
get #1, , bytebuff
close #1
You then decrypt it,
for x = 0 to ubound(bytebuff)
bytebuff(x) = bytebuff(x) xor i
next x
And place it back in the encrypted/decrypted file
open decryptedfilename for binary as #1
put #1, , bytebuff
close #1
and your done!
(WARNING NOT VERY SAFE, KEEP OUT OF REACH OF SMALL CHILDREN)
DENC
like,
inp = inputbox("What is the password?")
You then turn int into a number,
i = 1
for x = 1 to len(inp)
i = i * asc(mid(Inp, x, 1))
i = (i mod 256) + 1
next x
i = i - 1
You then open the file for binary as #1 and dump the contents into a byte-buffer
dim bytebuff() as byte
open filename for binary as #1
redim bytebuff(lof(1))
get #1, , bytebuff
close #1
You then decrypt it,
for x = 0 to ubound(bytebuff)
bytebuff(x) = bytebuff(x) xor i
next x
And place it back in the encrypted/decrypted file
open decryptedfilename for binary as #1
put #1, , bytebuff
close #1
and your done!
(WARNING NOT VERY SAFE, KEEP OUT OF REACH OF SMALL CHILDREN)
DENC
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement