十六进制解码
In
在
Easy String Encryption Using CryptoAPI in C++ I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may contain embedded NULLs or other characters that can cause processing problems.
在C ++中使用CryptoAPI进行简单的字符串加密我描述了如何加密文本,并建议将加密的文本存储为一系列十六进制数字-因为密文可能包含嵌入的NULL或其他可能导致处理问题的字符。
Since then I've worked on an application in which large blocks of binary data must be encoded into hexadecimal rapidly, and when needed, decoded back to binary just as rapidly. In the earlier article, I provided a sort of "throw-away" hex encoder/decoder, but I felt that I needed something that was more efficient for production work.
从那时起,我就致力于一个应用程序,在该应用程序中,必须将大型二进制数据块快速编码为十六进制,并在需要时将其解码为二进制。 在较早的文章中,我提供了一种“扔掉”的十六进制编码器/解码器,但我觉得我需要对生产工作更加有效的东西。
In this article, I'll explore some hex encode/decode options, including the one supported by the CryptoAPI, and at the end of the article, I'll present the ultra-fast functions that ended up in my production code.
在本文中,我将探讨一些十六进制编码/解码选项,包括
Observe the ordering of characters in an ASCII Table The only real issue with hex encoding is that there is a gap between the 9 and the A. Most of the complications come when dealing with that.
观察中字符的顺序十六进制编码的唯一真正问题是与之间存在间隙。 大多数并发症是在处理这些问题时出现的。
How to Encode to Hexadecimal
Your binary source byte is 8 bits. Take the data 4 bits at a time (values 0-15). If that value is 0-9, then just add '0' (0x30). If the value is 10-15, then add 0x37 instead. That gives you a hex digit ('0', '1',...,'9','A',..., 'F'). Output the resulting high hex digit followed by the low hex digit.
您的二进制源字节为8位。 一次取4位数据(值0-15)。 如果该值为0-9,则只需添加“ 0”(0x30)。 如果值为10-15,则添加0x37。 这会给您一个十六进制数字(“ 0”,“ 1”,...,“ 9”,“ A”,...,“ F”)。 输出结果高位十六进制数字,然后输出低位十六进制数字。
significantproblem when the output is large. Let me explain...
Significant Problem with Long Strings
Each time you concatenate to an existing CString (or an STL string object), the code must check to see if that current allocation is large enough. If not, it must allocate a new chunk that is larger, and copy the existing contents to that location before appending the new text. Imagine how clumsy that gets when the string is about 1MB long!
每次连接到
到此这篇16进制解码(16进制解码最简单方法)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/bcyy/67933.html