Käytännössä täyden turvan takaamiseksi avain olisi myös kuljetettava offlinenä suoraan tulevien viestien lähettäjältä niiden vastaanottajalle laitakaupungin hämärissä yöneljältä ja varmistettava, ettei kumpaakaan osapuolta seurata. Popliinitakkia suositellaan.
EDIT: Innostuinpa kirjoittamaan vielä pienoisen ohjelman, joka kirjoittelee kuvaamani tapaista salakirjoitusta. Avaimena kannattaa kokeilla käyttää mm. valokuvaa tai äänitiedostoa, ellei viesti ole tarpeeksi lyhyt näppäimistöä hakkaamalla generoitavalle avaimelle :)
Code: Select all
SCREEN 300,80
SetFont LoadFont("arial",13)
state = 0
prevstate = 0
dott$ = "."
t=Timer()
Function modd(a)
While a<0
a=a+256
Wend
While a>255
a=a-256
Wend
Return a
EndFunction
Repeat
Select state
Case 0
Text 5, 5, "Do you want to encrypt (1) or decrypt (2) ?"
a = GetKey()
If a=Asc("1") Then state = 1
If a=Asc("2") Then state = 8
Case 1
Text 5, 5, "Give the file to be encrypted:"
Locate 5, 15
i$=Input("> ")
If KeyHit(28) Then CloseInput:state = 3
If state = 3 And FileExists(i)=0 Then prevstate=1:state=20
Case 3
Text 5, 5, "Give the key file:"
Locate 5, 15
j$=Input("> ")
If KeyHit(28) Then CloseInput:state = 4:dott=""
If state = 4 And FileExists(j)=0 Then prevstate=3:state=20:p=0
Case 4
f1 = OpenToRead(i)
f2 = OpenToRead(j)
f3 = OpenToWrite("enc."+i)
state = 5
Case 5
Text 5, 5, "Encrypting"+dott
For k = 0 To 100
WriteByte f3, modd(ReadByte(f1)+ReadByte(f2))
If EOF(f1) Then state=6:Exit
If EOF(f2) Then state=22:Exit
Next k
Case 6
CloseFile f1
CloseFile f2
CloseFile f3
state=7
Case 7
a = GetKey()
Text 5, 5, "File '"+i+"' encrypted with file '"+j+"'."
Text 5,15, "The result file was saved a"+"s 'enc."+i+"'."
Text 5,25, "Press any key t"+"o e"+"xit."
If a Then End
Case 8
Text 5, 5, "Give the file to be decrypted:"
Locate 5, 15
i$=Input("> ")
If KeyHit(28) Then CloseInput:state = 9
If state = 9 And FileExists(i)=0 Then prevstate=8:state=20
Case 9
Text 5, 5, "Give the key file:"
Locate 5, 15
j$=Input("> ")
If KeyHit(28) Then CloseInput:state = 10:dott=""
If state = 10 And FileExists(j)=0 Then prevstate=9:state=20:p=0
Case 10
f1 = OpenToRead(i)
f2 = OpenToRead(j)
f3 = OpenToWrite("dec."+i)
state = 11
Case 11
Text 5, 5, "Decrypting"+dott
For k = 0 To 100
WriteByte f3, modd(ReadByte(f1)-ReadByte(f2))
If EOF(f1) Then state=12:Exit
If EOF(f2) Then state=22:Exit
Next k
Case 12
CloseFile f1
CloseFile f2
CloseFile f3
state = 13
Case 13
a = GetKey()
Text 5, 5, "File '"+i+"' decrypted with file '"+j+"'."
Text 5,15, "The result file was saved a"+"s 'dec."+i+"'."
Text 5,25, "Press any key t"+"o e"+"xit."
If a Then End
Case 20
Text 5, 5, "Bad file, try again? Yes (1) o"+"r no (2) ."
a = GetKey()
If a=Asc("1") Then state = prevstate
If a=Asc("2") Then state = 11
Case 21
a = GetKey()
Text 5, 5, "Exiting now, press a key."
If a Then End
Case 22
CloseFile f1
CloseFile f2
CloseFile f3
DeleteFile i+".enc"
a = GetKey()
Text 5, 5, "Key too s"+"hort, press any key t"+"o e"+"xit."
If a Then End
EndSelect
if Timer()>t Then dott = dott + ".":t=t+250
If Len(dott)>3 Then dott = ""
DrawScreen
Forever