当前位置:网站首页>Base64和Base64URL
Base64和Base64URL
2022-07-03 08:05:00 【AI-剁椒鱼头】
Base64编码简介
首先,Base64是一种编码方式,而不是真正的加密方式。即使算,Base64 也仅用作一个简单的“加密”来保护某些数据,而真正的加密通常都比较繁琐。
Base64使用64个通用的可打印字符来存储和表示二进制字数据,同时也可以进行简单的加密,生成不可读文本。Base64字符集包括大、小写英文字母,阿拉伯数字0-9,以及"+“和”/“,以及作后缀填充的”=“共计65个字符,其中编码时只使用前64个。如何使用这64个字符来表示二进制数据呢?这就需要在十进制的0到63以及使用的64个字符之间建立一一对应关系。具体的映射是将十进制的0到63依次与"A-Z”, “a-z”, “0-9”, “+”, "/"一一对应。在计算机中64种可能只需要6bits就能表达(26=64),因此Base64表示法实质上是以6bits为单位,使用规定的通用字符集来表示和存储二进制数据。
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 | / |
使用工具 http://www.lzltool.com/base64 可以在线解析Base64,将Base64转换成字符串或十六进制、或Base64Url格式
Base64URL编码简介
由于标准的Base64编码后可能出现字符+和/,在URL中就不能直接作为参数,所以又有一种"url safe"的base64编码,其实就是把字符+和/分别变成-和_
由于=字符也可能出现在Base64编码中,但=用在URL、Cookie里面会造成歧义,所以,Base64URL编码后会把=去掉
去掉=后怎么解码呢?因为Base64是把3个字节变为4个字节,所以,Base64编码的长度永远是4的倍数,因此,需要加上=把Base64字符串的长度变为4的倍数,就可以正常解码了。
使用工具 http://www.lzltool.com/base64url 可以在线解析Base64URL,将Base64URL转换成字符串或十六进制、或Base64格式
边栏推荐
- Huawei s5700 switch initialization and configuration Telnet, SSH user methods
- Huawei switch console password reset, device initialization, default password
- vcs import src < ros2. Repos failed
- Zohocrm deluge function application time verification
- unity2019_ Input management
- Wechat applet taro learning record
- Lua hot update basic grammar
- Oracle insert single quotation mark
- *p++、*++p、++*p、(*p)++
- freetype库的移植
猜你喜欢

【cocos creator】点击按钮切换界面

Viz artist advanced script video tutorial -- stringmap use and vertex operation

My touch screen production "brief history" 1
![[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)](/img/de/1c75b5e7ed79aca47462de365428a7.jpg)
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)

Storage of data

璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型

VMware virtual machine configuration static IP

An article for you to understand - Manchester code

JS common basic case sorting (continuous update)

Transfinite hacker cognition
随机推荐
Haproxy+kept cluster setup 02
Open the influence list of "National Meteorological Short Videos (Kwai, Tiktok) in November" in an interactive way“
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
JS regular case-
Redis view client connection
WorldView卫星遥感影像数据/米级分辨率遥感影像
P2704 [noi2001] artillery position (shape pressure DP)
Ilruntime learning - start from scratch
Huawei switch: configure Telnet, SSH and web access
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
使用 FileChannel 进行文件的复制拷贝
P1896 [SCOI2005] 互不侵犯(状压dp)
Getting started with minicom
Golang的range
The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.
Multi traveling salesman problem -- overview of formula and solution process
Quelle est la définition? Qu'est - ce qu'une déclaration? Quelle est la différence?
Pulitzer Prize in the field of information graphics - malofiej Award
[cocos creator] Click the button to switch the interface
Unity change default editor