Blockchifre
Verfasst: 26.02.2008 01:06
So Leute ich hab mal eine Frage:
Ich hab mir selber ein Blockchifre mit 128 bit gemacht,
ob es sicher ist sei dahin gestellt,
will damit ja nur kleine Kinder abschrecken,
ne aber mal Spass bei seite.
Also, eine Datei wird selten genau durch 16 Teilbar sein und da ich ja in meiner Verschlüsselung immer 16 byte rausbekomm ist die Frage wie ich die letzten 1-15 Bytes Verschlüssle ohne sie möglicher weiße nach dem entschlüsseln zu beschädigen?
Mir gehn die Ideen aus ^^
Und für intresierte hier der Algo:
Verschlüsseln:
Entschlüssenln:
Ich hab mir selber ein Blockchifre mit 128 bit gemacht,
ob es sicher ist sei dahin gestellt,
will damit ja nur kleine Kinder abschrecken,

ne aber mal Spass bei seite.
Also, eine Datei wird selten genau durch 16 Teilbar sein und da ich ja in meiner Verschlüsselung immer 16 byte rausbekomm ist die Frage wie ich die letzten 1-15 Bytes Verschlüssle ohne sie möglicher weiße nach dem entschlüsseln zu beschädigen?
Mir gehn die Ideen aus ^^
Und für intresierte hier der Algo:
Verschlüsseln:
Code: Alles auswählen
Procedure Quersumme(zahl.q)
Protected Result.l
If zahl < 0 : zahl * -1 : EndIf
While zahl
Result + zahl % 10
zahl / 10
Wend
ProcedureReturn Result
EndProcedure
Procedure.s FriZaV(text$,pawo$)
Dim text.w(5,5)
Dim pawo.w(5,5)
For y = 1 To 4
For x = 1 To 4
z = y + ((x-1) * 4)
text(x,y) = Asc(Right(Left(text$,z),1))
pawo(x,y) = Asc(Right(Left(pawo$,z),1))
Next x
Next y
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For y = 1 To 4
For x = 1 To 4
byte = text(x,y)
byte = byte + pawo(x,y)
If byte > 255
byte - 255
EndIf
text(x,y) = byte
Next x
Next y
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For z = 1 To 15
text(1,5) = text(1,1)
text(1,1) = text(1,2)
text(1,2) = text(1,3)
text(1,3) = text(1,4)
text(1,4) = text(1,5)
text(2,5) = text(2,1)
text(2,1) = text(2,3)
text(2,3) = text(2,5)
text(2,5) = text(2,2)
text(2,2) = text(2,4)
text(2,4) = text(2,5)
text(3,5) = text(3,1)
text(3,1) = text(3,4)
text(3,4) = text(3,3)
text(3,3) = text(3,2)
text(3,2) = text(3,5)
text(1,5) = text(1,1)
text(2,5) = text(2,1)
text(3,5) = text(3,1)
text(4,5) = text(4,1)
text(1,1) = text(1,3)
text(2,1) = text(2,3)
text(3,1) = text(3,3)
text(4,1) = text(4,3)
text(1,3) = text(1,5)
text(2,3) = text(2,5)
text(3,3) = text(3,5)
text(4,3) = text(4,5)
text(1,5) = text(1,2)
text(2,5) = text(2,2)
text(3,5) = text(3,2)
text(4,5) = text(4,2)
text(1,2) = text(1,4)
text(2,2) = text(2,4)
text(3,2) = text(3,4)
text(4,2) = text(4,4)
text(1,4) = text(1,5)
text(2,4) = text(2,5)
text(3,4) = text(3,5)
text(4,4) = text(4,5)
quer = 0
For x = 1 To 16
quer = quer + Asc(Right(Left(pawo$,x),1))
Next x
Repeat
quer = Quersumme(quer)
Until quer < 10
If quer <= 4
line = 1
ElseIf quer <= 8
line = 2
quer = quer - 4
Else
line = 3
quer = quer - 8
EndIf
text(5,1) = text(quer,line)
text(quer,line) = text(1,1)
text(1,1) = text(5,1)
quer = Quersumme(quer*2)
If quer <= 4
line = 1
ElseIf quer <= 8
line = 2
quer = quer - 4
Else
line = 3
quer = quer - 8
EndIf
text(5,1) = text(quer,line)
text(quer,line) = text(1,1)
text(1,1) = text(5,1)
Next z
For y = 1 To 4
For x = 1 To 4
byte = text(x,y)
byte = byte + pawo(x,y)
If byte > 255
byte - 255
EndIf
text(x,y) = byte
Next x
Next y
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For x = 1 To 4
For y = 1 To 4
chif1$ = chif1$ + Chr(text(x,y))
Next y
Next x
ProcedureReturn chif1$
EndProcedure
Debug FriZaV("Goldregenpfeifer","abcdefghijklmnop")
Code: Alles auswählen
Procedure Quersumme(zahl.q)
Protected Result.l
If zahl < 0 : zahl * -1 : EndIf
While zahl
Result + zahl % 10
zahl / 10
Wend
ProcedureReturn Result
EndProcedure
Procedure.s FriZaE(text$,pawo$)
Dim text.w(5,5)
Dim pawo.w(5,5)
For y = 1 To 4
For x = 1 To 4
z = y + ((x-1) * 4)
text(x,y) = Asc(Right(Left(text$,z),1))
pawo(x,y) = Asc(Right(Left(pawo$,z),1))
Next x
Next y
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For y = 1 To 4
For x = 1 To 4
byte = text(x,y)
byte = byte - pawo(x,y)
If byte < 0
byte + 255
EndIf
text(x,y) = byte
Next x
Next y
For z = 1 To 15
quer = 0
For x = 1 To 16
quer = quer + Asc(Right(Left(pawo$,x),1))
Next x
Repeat
quer = Quersumme(quer)
Until quer < 10
quer2 = Quersumme(quer*2)
If quer <= 4
line = 1
ElseIf quer <= 8
line = 2
quer = quer - 4
Else
line = 3
quer = quer - 8
EndIf
If quer2 <= 4
line2 = 1
ElseIf quer2 <= 8
line2 = 2
quer2 = quer2 - 4
Else
line2 = 3
quer2 = quer2 - 8
EndIf
text(5,1) = text(1,1)
text(1,1) = text(quer2,line2)
text(quer2,line2) = text(5,1)
text(5,1) = text(1,1)
text(1,1) = text(quer,line)
text(quer,line) = text(5,1)
text(4,5) = text(4,2)
text(3,5) = text(3,2)
text(2,5) = text(2,2)
text(1,5) = text(1,2)
text(4,2) = text(4,4)
text(3,2) = text(3,4)
text(2,2) = text(2,4)
text(1,2) = text(1,4)
text(4,4) = text(4,5)
text(3,4) = text(3,5)
text(2,4) = text(2,5)
text(1,4) = text(1,5)
text(4,5) = text(4,1)
text(3,5) = text(3,1)
text(2,5) = text(2,1)
text(1,5) = text(1,1)
text(4,1) = text(4,3)
text(3,1) = text(3,3)
text(2,1) = text(2,3)
text(1,1) = text(1,3)
text(4,3) = text(4,5)
text(3,3) = text(3,5)
text(2,3) = text(2,5)
text(1,3) = text(1,5)
text(3,5) = text(3,1)
text(3,1) = text(3,2)
text(3,2) = text(3,3)
text(3,3) = text(3,4)
text(3,4) = text(3,5)
text(2,5) = text(2,4)
text(2,4) = text(2,2)
text(2,2) = text(2,5)
text(2,5) = text(2,3)
text(2,3) = text(2,1)
text(2,1) = text(2,5)
text(1,5) = text(1,4)
text(1,4) = text(1,3)
text(1,3) = text(1,2)
text(1,2) = text(1,1)
text(1,1) = text(1,5)
Next z
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For y = 1 To 4
For x = 1 To 4
byte = text(x,y)
byte = byte - pawo(x,y)
If byte < 0
byte + 255
EndIf
text(x,y) = byte
Next x
Next y
For y = 1 To 4
For x = 1 To 4
hex$ = RSet(Hex(text(x,y)), 2, "0")
taus0$ = Left(hex$,1)
taus1$ = Right(hex$,1)
hex$ = taus1$ + taus0$
text(x,y) = Hex2Dec(hex$)
Next x
Next y
For x = 1 To 4
For y = 1 To 4
chif1$ = chif1$ + Chr(text(x,y))
Next y
Next x
ProcedureReturn chif1$
EndProcedure
Debug FriZaE("ámÏ