'Obs!:Sätt strKey till den nyckel som skall användas för att kryptera eller
' dekryptera filen.
' Sätt strInPath till den fil som skall krypteras/dekrypteras
' Sätt strOutPath till den fil som skall skrivas som krypterad/dekrypterad
'===================================================
Public Sub XOREncDecFile(strKey As String, strInPath As String, strOutPath As String)
Dim strInput As String
Dim strOutput As String
Dim dblX As Double
Open strInPath For Binary As #1
strInput = Input(LOF(1), 1)
Close #1
For dblX = 1 To Len(strInput)
strKey = strKey & strKey
If Len(strKey) >= Len(strInput) Then
dblX = Len(strInput)
End If
Next dblX
For dblX = 1 To Len(strInput)
strOutput = strOutput & Chr(Asc(Mid(strInput, dblX, 1)) Xor Asc(Mid(strKey, dblX, 1)))
Next dblX
Open strOutPath For Binary As #1
Put #1, , strOutput
Close #1
End Sub