我有一个简单的函数,用模运算符处理溢出
Private Function RandomizeBlock(seed As Integer, ByVal block() As Byte) As Byte()
Dim Generator As System.Random = New System.Random(seed)
Dim newblock(255) As Byte
Dim i As Integer = 0
For i = 0 To block.Length - 1
newblock(i) = (block(i) + Generator.Next(0, 256)) Mod 256
Next
Return newblock
End Function
如何撤消对块进行的随机化?
我知道 mod 是这样工作的:
253,254,255,0,1,2,3,4
覆盖在0
.
我能找到这里的倒数reverse
吗?
rndValue = Generator.Next(0, 256)
reverse_1 = ((256 - rndValue) + block(i)) Mod 256
reverse_2 = ((256 + rndValue) - block(i)) Mod 256