【发布时间】:2012-11-21 07:02:33
【问题描述】:
我需要c#中的以下逻辑:
Dim sampleText As String, Key As String;
Dim KeyLength As Long, Position As Long;
Dim character as integer;
For Position = 1 To Len(sampleText)
character = Asc(Mid$(Key, (Position Mod KeyLength) - KeyLength * ((Position Mod KeyLength) = 0), 1))
Mid$(sampleText, Position, 1) = Chr(Asc(Mid$(sampleText, Position, 1)) Xor character)
Next Position
【问题讨论】:
-
我面临的主要问题是以下行: character = Asc(Mid$(Key, (Position Mod KeyLength) - KeyLength * ((Position Mod KeyLength) = 0), 1))我对末尾的“=0”有疑问。
-
那是极弱的 XOR 加密。您可以查看 .Net 库中的一些更强大的加密。
-
以下表达式如何计算出一个值:abc= (position % keylength) - keylength*(position % keylength)==0)