当前位置:网站首页 > 编程语言 > 正文

16进制解码(16进制解码最简单方法)



十六进制解码

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”)。 输出结果高位十六进制数字,然后输出低位十六进制数字。

significant

problem 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进制解码最简单方法)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • max3042 中文手册(max3096中文手册)2025-04-01 09:00:05
  • git的用法(git常用操作详解)2025-04-01 09:00:05
  • 2263xt 跳线(2262en跳线)2025-04-01 09:00:05
  • samba共享怎么用(如何设置samba共享)2025-04-01 09:00:05
  • py文件怎么执行 linux(py文件怎么执行)2025-04-01 09:00:05
  • 打印机共享错误怎么办(打印机共享显示错误该怎么办)2025-04-01 09:00:05
  • 动态库存表(动态库存表格怎么制作)2025-04-01 09:00:05
  • 断开连接是什么意思kpl(adsl已断开连接是什么意思)2025-04-01 09:00:05
  • 圈一圈英文怎么读(一圈一圈英文)2025-04-01 09:00:05
  • siim是什么意思中文(silmy什么意思)2025-04-01 09:00:05
  • 全屏图片