当前位置:网站首页>Base64与16进制HEX之间的转换
Base64与16进制HEX之间的转换
2022-08-06 03:45:00 【robur】
Base64编码是使用64个可打印ASCII字符(A-Z、a-z、0-9、+、/)将任意“字节序列”数据编码成ASCII字符串,另有“=”符号用作后缀用途。
因此,Base64不但可以处理常见的文本信息,也可以用于处理二进制数据。
Base64的编码规则如下:
- 将整个字节序列转换为一长串二进制数;
- 按6bit进行分组;
- 如果最后一组的长度不足6bit,则再最后补0,直到长度达到6bit;
- 然后依据索引表,将6bit组转换为对应的ASCII字符。
Base64 索引表
(注:表中的数值为十进制)
数值 字符 数值 字符 数值 字符 数值 字符 0 A 16 Q 32 g 48 w 1 B 17 R 33 h 49 x 2 C 18 S 34 i 50 y 3 D 19 T 35 j 51 z 4 E 20 U 36 k 52 0 5 F 21 V 37 l 53 1 6 G 22 W 38 m 54 2 7 H 23 X 39 n 55 3 8 I 24 Y 40 o 56 4 9 J 25 Z 41 p 57 5 10 K 26 a 42 q 58 6 11 L 27 b 43 r 59 7 12 M 28 c 44 s 60 8 13 N 29 d 45 t 61 9 14 O 30 e 46 u 62 + 15 P 31 f 47 v 63 /例子:
十六进制数据:FD FA 8E A5 45 55 A5 E4(共8字节)
转换为二进制:1111110111111010 1000111010100101 0100010101010101 1010010111100100
按6bit分组:111111-011111-101010-001110-101001-010100-010101-010101-101001-011110-0100【00】(方括号内是在最低位补充的2bit 0)
查表转换为ASCII字符:/fqOpUVVpeQ=(共11个字符,等于号是后缀)
更多内容参考:
边栏推荐
- 新搭建的国家广告系列,是否要排除掉旧的广告系列?
- 自定义View,和Canvas(画布),Paint(画笔),Path(路径)的用法
- Is Tmall Qixi Festival cheap in 2022? What discounts will Tmall Qixi Festival have?
- sql server , 两个表,相同字段,相同数据量(5000万), 执行相同的查询,一个表执行的是索引扫描,扫描5000万,耗时2分钟, 另一个表执行的是索引查找,只查找10万,耗时1秒。为什么会有这么大的差别?
- Digital Smart Factory Solutions 47 pages
- 2022年京东新百货七夕礼遇季活动有什么亮点?
- LabVIEW 应用程序视窗始终置于顶层
- 泡沫填充轮胎
- If a country's market effect is particularly good, how can we increase the proportion of this country's investment?
- 电赛的控制类选题之问
猜你喜欢

Use BeanUtils with caution, the performance really stretches!

Django用orm修改mysql数据库运行出现错误

Jvm: synchronized锁定谁?

电赛的控制类选题之问

Crypto Bear Market Offers M&A Opportunity Ambitious or Savior?The only truth is that interests come first

Programmer's first day at work | Daily anecdote

Practical Application Case of Digital Twin - Smart Port

喜欢我们不如加入我们:来投稿吧,稿酬靠谱!

What are the big events on Tmall in August 2022?

89. (home of cesium) cesium aggregation graph (custom image)
随机推荐
Digital Smart Factory Solutions 47 pages
If you like us, it is better to join us: come and contribute, the payment is reliable!
Linux common commands
What are the highlights of the 2022 Jingdong New Department Store Qixi Festival Promotion Season?
Lvm root partition expansion
Entering the pit of machine learning: three, unsupervised learning
2018HBCPC Partial Solutions
谷歌账户暂停三个月重新启用,谷歌账户暂停三个月重新启用,转化目标是否有效?
Can HTAP replace OLAP?
新搭建的国家广告系列,是否要排除掉旧的广告系列?
数字孪生实际应用案例-智慧港口篇
自定义View,和Canvas(画布),Paint(画笔),Path(路径)的用法
xctf attack and defense world web master advanced area command_execution
浦发银行长沙分行党委书记、行长王起,华融湘江银行行长蒋俊文一行莅临麒麟信安调研考察
To build their own core, let Google pay!Google has open source 180 nm process chip
LeetCode:623. 在二叉树中增加一行【DFS or BFS】
If a country's market effect is particularly good, how can we increase the proportion of this country's investment?
Qixi Festival WeChat confession wall applet source code / Laravel-based confession wall WeChat applet source code
洛谷: P1057 [NOIP2008 普及组] 传球游戏
ctf (finalrec)