WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Encryption

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

XOR Pad Type Encryption

Keywords:   XOR Pad type encryption

This is called a "pad" type encryption. You MUST preserve the "keyfile." If you do not have the key file, then there is ABSOLUTELY no way to recover the data. It should be a sort of compressed file. ZIPS, JPG's and MP3 seems to work pretty good.

The key file should be larger than the data file you wish to encrypt.

;Encrypt

datafile="C:\BizDocs\Incoming\bigdlg.txt"
protfile="C:\BizDocs\Incoming\bigdlg.prot"

datafilesize=FileSize(datafile)

bbdata=BinaryAlloc(datafilesize)
bbkey=BinaryAlloc(datafilesize)

BinaryRead(bbdata,datafile)
for xx=1 to datafilesize
   BinaryPoke(bbkey,xx-1, (datafilesize+xx) mod 255)
next
BinaryXOR(bbdata,0,bbkey,0,datafilesize)

BinaryWrite(bbdata,protfile)
BinaryFree(bbdata)
BinaryFree(bbkey)

Message(protfile,"File encrypted")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Decrypt

protfile="C:\BizDocs\Incoming\bigdlg.prot"
outputfile="C:\BizDocs\Incoming\bigdlg.new"

datafilesize=FileSize(protfile)

bbdata=BinaryAlloc(datafilesize)
bbkey=BinaryAlloc(datafilesize)

BinaryRead(bbdata,protfile)
for xx=1 to datafilesize
   BinaryPoke(bbkey,xx-1, (datafilesize+xx) mod 255)
next

BinaryXOR(bbdata,0,bbkey,0,datafilesize)

BinaryWrite(bbdata,outputfile)
BinaryFree(bbdata)
BinaryFree(bbkey)

Message(outputfile,"File decrypted")

Article ID:   W15292
File Created: 2002:09:05:13:51:06
Last Updated: 2002:09:05:13:51:06