校验和运算(FF = h1 xor h2 ...) [英] Checksum operation (FF = h1 xor h2...)

查看:100
本文介绍了校验和运算(FF = h1 xor h2 ...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我对财务打印机的计数校验和有严重的疑问.

主要规则是:

FF = FF xor hex1 xor hex2 xor hex3(...)

然后我应该得到一些十六进制值(两个符号,例如B7).

稍后将此值(B7)分配给B和7,并将其另存为十六进制(B为十六进制,而7为十六进制).

我对十六进制不满意,所以anybdody可以在vb.net上给我写一些代码吗?

在此先感谢.

Hello,

I have a serious problem with count checksum of fiscal printer.

Main rule is:

FF = FF xor hex1 xor hex2 xor hex3 (...)

and then I should get some hexadecimal value (two signs, for example B7).

Later this value (B7) I should spread on B and 7 and save it as hex (B as hex and 7 as hex).

I''m not good with hex so can anybdody write me some code in vb.net?

Thanks in advance.

推荐答案

没有另存为十六进制"之类的东西.十六进制表示. 10十进制和0A十六进制是同一件事,写法不同.因此,除非您需要使用string.Format将数字可视化为十六进制格式,否则唯一的问题是您需要使用位掩码将数字分为两部分.您应该解释另存为十六进制"的含义,是否需要将B和7分别保存为字符?如果是这样,您可以将您的数字转换为十六进制,然后将字符串分割.
There is no such thing as ''save as hex''. Hex is a representation. 10 Decimal and 0A hex are the same thing, written differently. So, unless you need to use string.Format to format your number visually as hex, the only issue you have is that you need to use bit masking to turn your number in to the two parts. You should explain what you mean by ''save as hex'', do you need to literally save B and then 7, as characters ? If so, you can turn your number to hex and then split the string.


Christian-您说对了,所以让我解释一下:

我有一些十六进制,例如:B7,A0,F2,C4.

现在我必须要做类似的事情:

FF = FF XOR B7 XOR A0 XOR F2 XOR C4

当我有值时,我必须将其分散在两个字符上(因为该值将由两个字符组成,对吗?),然后将它们转换为十六进制. :)
Christian - You have right, so let me explain:

i have some hex, for example: B7, A0, F2, C4.

Now I have to do something like that:

FF = FF XOR B7 XOR A0 XOR F2 XOR C4

and when I have value I must spread it on two characters (because this value will consist of two characters, right?), and convert them to hex. :)


这篇关于校验和运算(FF = h1 xor h2 ...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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