请帮助我有关此功能. [英] Plz Help me about this function.

查看:69
本文介绍了请帮助我有关此功能.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们!我已经下载了VB源代码.在此源代码中,我找到了一个功能.功能如下

Dear Friends! I have downloaded a VB Source Code. In this source code I have found a Function. The Function is as follows

Private Function XorPassword(Bytes As Variant) As String
    Dim XorBytes()      As Variant
    Dim strPassword     As String
    Dim intIndex        As Integer
    Dim CurrChar        As String * 1
    XorBytes = Array(&H86, &HFB, &HEC, &H37, &H5D, &H44, &H9C, &HFA, &HC6, &H5E, &H28,HE6, &H13, &HB6, &H8A, &H60, &H54, &H94)
    strPassword = vbNullString
    intIndex = 0
    Do
    'Get a character from the password by doing a XOR with the
    'appropriate value in XorBytes array.
        CurrChar = Chr$(Bytes(intIndex + &H42) Xor XorBytes(intIndex))
        'If we get a Null character, get out of the loop.
        If Asc(CurrChar) = 0 Then Exit Do
        'Add the password character to the accumulated password string.
        strPassword = strPassword & CurrChar
        intIndex = intIndex + 1
    Loop Until intIndex = 17
    XorPassword = strPassword
End Function



在此函数中,我无法理解以下数组



In this Function I could not understand the following array

XorBytes = Array(&H86, &HFB, &HEC, &H37, &H5D, &H44, &H9C, &HFA, &HC6, &H5E, &H28,HE6, &H13, &HB6, &H8A, &H60, &H54, &H94)



我的问题是,为什么他在此数组中使用了这些十六进制值,其背后的逻辑是什么?

请帮我解决这个问题.我将感谢您.



My Question is that Why he has used these Hex Values in this array and what is the logic behind that?

Plz Help me about this. I will be thankful to you.

推荐答案

(Bytes(intIndex +& H42) Xor XorBytes( intIndex)) ' 如果我们得到一个Null字符,请退出循环. 如果 Asc(CurrChar)= 0 然后 退出 执行 ' 将密码字符添加到累积的密码字符串中. strPassword = strPassword& CurrChar intIndex = intIndex + 1 循环,直到intIndex = 17 XorPassword = strPassword 结束 功能
(Bytes(intIndex + &H42) Xor XorBytes(intIndex)) 'If we get a Null character, get out of the loop. If Asc(CurrChar) = 0 Then Exit Do 'Add the password character to the accumulated password string. strPassword = strPassword & CurrChar intIndex = intIndex + 1 Loop Until intIndex = 17 XorPassword = strPassword End Function



在此函数中,我无法理解以下数组



In this Function I could not understand the following array

XorBytes = Array(&H86, &HFB, &HEC, &H37, &H5D, &H44, &H9C, &HFA, &HC6, &H5E, &H28,HE6, &H13, &HB6, &H8A, &H60, &H54, &H94)



我的问题是,为什么他在此数组中使用了这些十六进制值,其背后的逻辑是什么?

请帮我解决这个问题.我将感谢您.



My Question is that Why he has used these Hex Values in this array and what is the logic behind that?

Plz Help me about this. I will be thankful to you.


如果您希望在自己的应用程序中使用此代码,请不要.这是一个非常琐碎的加密"方案,很容易破解,并且将加密值硬编码到代码中,如果有人将其破解,则无法更改密钥.
If you''re looking to use this code in your own application, don''t. This is a very trivial "encryption" scheme, very easily broken, and with the encryption values hard coded into the code, if someone does break it, you can''t change the key.


你好拉希德,

这是对字节数组的某些部分进行编码的非常简单的算法.数组的编码部分在位置66 dec开始.最长为17个字符.当该部分不扩展17个字符时,零字节将终止编码.

这种编码类似于一次性"加密方案:
A xor B = C
C xor B = A

对于字符串中的每个位置,都使用不同的字节来编码和
将编码后的字符串输入该函数时,其效果就是将其解码为原始字符串.

A是输入,C是输出,B是数组中的特殊十六进制代码.

希望这会有所帮助!

欢呼声

曼弗雷德(Manfred)
Hello Rashid,

this is a very trivial algorithm to encode acertain portion of an array of bytes. The encoded section of the array starts at position 66 dec. and can be at most 17 characters long. A zero byte terminates the encoding when the section does not extend 17 characters.

This kind of encoding works analog to the "one time pad" encryption scheme:
A xor B = C
C xor B = A

For every position in the string a different byte is used to encode and
when feeding the encoded string into the function the effect is that of decoding it into the original.

A is the input, C is the output and B is the special hex code from the array.

Hope this helps!

Cheers

Manfred


这篇关于请帮助我有关此功能.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆