Daher genügt letztlich ein Verfahren, dass ein Bit, eine Null oder eine Eins, verschlüsseln kann. Es gibt offenbar nur zwei Möglichkeiten. Das Bit bleibt unverändert oder in den anderen Wert (0->1, 1->0) verwandelt. Zum Verschlüsseln genügt also ein Bit. Eins heißt verändern, Null heißt bleibt unverändert. Wenn jetzt Bit für Bit mit zufällig gewählten Bits verschlüsselt wird, haben wir das One-Time-Pad, dass bekanntlich unknackbar ist.
Damit ist das Problem der Verschlüsselung auf die Erzeugung einer Folge von Zufallsbits zurückgeführt. Wenn Sender und Empfänger mit einer Software die gleiche Zufallsfolge erzeugen können, dann können sie sich geheime Botschaften austauschen.
Es bleibt nur das Problem, die Software zur Erzeugung der Zufallsfolgen auszutauschen. Dies ist auch kein großes Problem, da eine solche Software zum Beispiel auf einer Mirco SD Karte, nicht größer als ein Fingernagel, ausgetauscht werden kann. mehr bei yigg.de

Willst Du 50MB verschlüsseln muss Deine Festplatte min. 100MB groß sein.
Völlig an der Praxis vorbei. Gehen tut das natürlich, sicher ist es auch, aber sehr unpraktisch.
#!/usr/bin/env python
#
# RC4, ARC4, ARCFOUR algorithm
#
# Copyright (c) 2009 joonis new media
# Author: Thimo Kraemer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
def rc4crypt(data, key):
x = 0
box = range(256)
for i in range(256):
x = (x + box[i] + ord(key[i % len(key)])) % 256
box[i], box[x] = box[x], box[i]
x = 0
y = 0
out = []
for char in data:
x = (x + 1) % 256
y = (y + box[x]) % 256
box[x], box[y] = box[y], box[x]
out.append(chr(ord(char) ^ box[(box[x] + box[y]) % 256]))
return ''.join(out)
def efile(fnam, fnamo, key):
f = open(fnam, 'rb')
f.seek(0,2)
flen = f.tell()
f.seek(0)
fo = open(fnamo, 'wb')
cnt = 0
while cnt < flen:
buf = f.read(1000)
cnt = cnt + len(buf)
fo.write( rc4crypt(buf, key) )
fo.close()
f.close()
return 'ALLES IN BUTTER'
Was hast Du gegen Festplattenverschlüsselungen wie Truecrypt oder Microsoft BItlocker?
def rc4crypt(data, key):
x = 0
box = range(256)
for i in range(256):
x = (x + box[i] + ord(key[i % len(key)])) % 256
box[i], box[x] = box[x], box[i]
x = 0
y = 0
out = []
for char in data:
x = (x + 1) % 256
y = (y + box[x]) % 256
box[x], box[y] = box[y], box[x]
out.append(chr(ord(char) ^ box[(box[x] + box[y]) % 256]))
return ''.join(out)
Das Fehler wird behoben wenn die Zeile
box = range(256)
mit der die S-Box initialisiert wird, vor die Funktion
box = range(256)
def rc4crypt(data, key):
....
geschrieben wird.
Dies Problematik wird vermieden, wenn die Zufallsfolge von den Daten abhänget. Dies wird zum Beispiel mit dem modifizierten Code erreicht.
box = range(256)
def rc4encrypt(data, key):
x = 0
for i in range(256):
x = (x + box[i] + ord(key[i % len(key)])) % 256
box[i], box[x] = box[x], box[i]
x = 0
y = 0
out = []
for char in data:
x = (x + 1) % 256
y = (y + box[x]) % 256
box[x], box[y] = box[y], box[x]
cx = ord(char) ^ box[(box[x] + box[y]) % 256]
out.append(chr(cx))
y = y + cx
return ''.join(out)
def rc4decrypt(data, key):
x = 0
for i in range(256):
x = (x + box[i] + ord(key[i % len(key)])) % 256
box[i], box[x] = box[x], box[i]
x = 0
y = 0
out = []
for char in data:
x = (x + 1) % 256
y = (y + box[x]) % 256
box[x], box[y] = box[y], box[x]
out.append(chr(ord(char) ^ box[(box[x] + box[y]) % 256]))
y = y + ord(char)
return ''.join(out)