我有一份由VB编辑的文件。 利用这一功能实施的净方案可产生以下影响:
Public Class Crypter
...
This Will convert String to bytes, then call the other function.
Public Function Crypt(ByVal Data As String) As String
Return Encoding.Default.GetString(Crypt(Encoding.Default.GetBytes(Data)))
End Function
This calls XorCrypt giving Key converted to bytes
Public Function Crypt(ByVal Data() As Byte) As Byte()
Return XorCrypt(Data, Encoding.Default.GetBytes(Me.Key))
End Function
Xor Encryption.
Private Function XorCrypt(ByVal Data() As Byte, ByVal Key() As Byte) As Byte()
Dim i As Integer
If Key.Length <> 0 Then
For i = 0 To Data.Length - 1
Data(i) = Data(i) Xor Key(i Mod Key.Length)
Next
End If
Return Data
End Function
End Class
并节省了这种方式:
Dim Crypter As New Cryptic(Key)
open destination file
Dim objWriter As New StreamWriter(fileName)
write crypted content
objWriter.Write(Crypter.Crypt(data))
现在,我不得不重开卷宗,但我有麻烦,要到single bytes,这是XOR在座的:
def crypto(self, data):
crypto(self, data) -> str
return .join(chr((ord(x) ^ ord(y)) % 256)
for (x, y) in izip(data.decode( utf-8 ), cycle(self.key))
我不得不增加256 %,因为有时x是“ &”;256,即:不是“灵丹”的单一产品。
两条经母体通过后,不会打破加密,因为钥匙将“搁置”与以下数据相连接。
The problem is some decrypted character in the conversion is wrong. These chars are all accented letters like à, è, ì but just a few of the overall accented letters. The others are all correctly restored.
我猜测,这可能是由于256次暴动造成的,但我当然没有例外。
感谢您的支持