麻烦再问,更好的解释...请帮助我:(
我问了这个问题,但是编码人员似乎不知道我想要什么,因为这很难解释.它使我发疯,所以病了要给她开枪.
好的,我的应用程序要求用户输入较长的安装ID:
50个十进制数字
分为每组六个数字,如
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
那么我们有:
删除校验位将产生41位十进制数. A
此长度的十进制数字大致对应于136位二进制
数字.实际上,41位数字只是
的十进制编码
这样的136位多精度整数,存储在little
endian字节顺序作为字节数组.因此,上述安装ID
也可以表示为17个字节的序列,如
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
0x00
所以我的问题是这样的:
如何将安装ID字符串("xxxxxx-xxxxxx-等")获取到上面的字节数组中,该字节数组表示数字的十进制编码.
这就是我想做的,以便我可以尝试使自己变得很清楚.
我想要一个固定长度的字节数组,例如:
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
0x00
然后,我将使用固定长度的密钥对字节数组进行加密.
然后,我想用字符串将字节数组表示为其数字表示形式:
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
我真的希望这会有所帮助.
再次谢谢你.
Steve
I have asked this question but but coders didnt seem to know what i wanted as it was hard to explain. It is driving me insane so ill give it anouther shot.
OK, My application asks the user to enter a long installation ID:
50 decimal digits that are
divided into groups of six digits each, as in
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
then we have:
Removing the check digits results in a 41-digit decimal number. A
decimal number of this length roughly corresponds to a 136-bit binary
number. In fact, the 41-digit number is just the decimal encoding of
such a 136-bit multi-precision integer, which is stored in little
endian byte order as a byte array. Hence, the above Installation ID
can also be represented as a sequence of 17 bytes as in
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
0x00
So my question is this:
How do i get the installation id string ("xxxxxx-xxxxxx- etc") into a byte array above, that represents the decimal encoding of the number.
This is what i want to do, just so i can try and make myself very clear.
I want a fixed length byte array, like:
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
0x00
I will then encrypt the byte array with a fixed length key.
I then want to represent the byte array as its number representation, in a string:
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
I realy hope this helps.
Thank you again.
Steve
尝试一下;
Try this;
string startValue = "456345-007876-343234-765676-543456-566565-321234-345654".Replace("-", "");
char[] indivualNumbers = startValue.ToCharArray();
byte[] arrayValue = new byte[indivualNumbers.Length];
int numberCounter = 0;
foreach (char numberValue in indivualNumbers)
{
arrayValue[numberCounter] = (byte)Convert.ToInt32(numberValue);
++numberCounter;
}
这是我在上一个问题中提供的第二个选项的最终结果.
This is the end result of the second option I gave in your previous question.
两个单词二进制数学".
您需要将字符串从最小有效数字移到最高有效.
将当前字符串值存储在一个字节中,调用此currentValue.
乘数再加上一个byte [].
和另一个byte []作为结果.
开始于;
Two words "Binary Math".
You need to walk the string from lest significant digit to most significant.
store the current string value in a byte call this currentValue.
have another byte[] with the multiplier.
and another byte[] for the result.
start off with;
byte[] multiplier = new byte[1];
multiplier[0] = 1;
byte currentValue = null;
byte[] result = new byte[1];
result[0] = 0;
foreach(char charValue in "5634007873432376567543455665632123345654".toCharArray().Reverse())
{
currentValue = (byte)Convert.ToInt16(charValue );
//Next two lines require binary math routines
result = result + (currentValue * multiplier);
multiplier = multiplier * 10;
}
显然,这是伪代码版本,因为字节数组,乘数和结果随着存储在它们中的数字变大而需要增加.
obviously this is the pseudocode version as the byte arrays, multiplier and result, will need to grow as the number stored in them gets larger.
再次感谢,但这不是我想要的. br/>
您的答案产生48个字节,正如我在上面试图解释的那样,该字符串的十进制表示形式应该为17个字节长.
我基本上是想在c#中重现以下内容
http://www.licenturion.com/xp/fully-licensed-wpa.txt
希望能有所帮助,因为我现在已经空白了,我也不会在意,但我之前找到了答案,无法再次得到它.
谢谢
史蒂夫
Thanks again but this is not what i want.
Your answer produces 48 bytes and as i am trying to explain above, the decimal representation of that string is supposed to be 17 bytes long.
I am basicaly trying to reproduce the following in c#
http://www.licenturion.com/xp/fully-licensed-wpa.txt
Hope that helps as i have now drew a blank, and i wouldnt care but i found the answer before and cant get it again.
Thank you
Steve