问题描述
我用PHP加密敏感数据并在Excel中处理数据。
function xor_string($string,$key) {
for($i = 0; $i < strlen($string); $i++)
$string[$i] = dechex(ord(($string[$i] ^ $key[$i % strlen($key)])));
return $string;
}
以下代码用于解密VBA中的字符串:
Public Function XORDecryption(CodeKey As String,DataIn As String) As String
Dim arkdata1 As Long
Dim strDataOut As String
Dim intXOrValue1 As Integer
Dim intXOrValue2 As Integer
For arkdata1 = 1 To (Len(DataIn) / 2)
'The first value to be XOr-ed comes from the data to be encrypted
intXOrValue1 = Val("&H" & (Mid$(DataIn,(2 * arkdata1) - 1,2)))
'The second value comes from the code key
intXOrValue2 = Asc(Mid$(CodeKey,((arkdata1 Mod Len(CodeKey)) + 1),1))
strDataOut = strDataOut + Chr(intXOrValue1 Xor intXOrValue2)
Next arkdata1
XORDecryption = strDataOut
End Function
加密过程: 使用字符串“ 123456897”和键“ 2405”,PHP函数返回“ 011151314f0”
解密过程: VBA函数使用字符串“ 011151314f0”和键“ 2405”返回“ 5!d {0”
我找不到VBA函数不返回“ 123456897”的原因:(
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)