ITÊýÂë ¹ºÎï ÍøÖ· Í·Ìõ Èí¼þ ÈÕÀú ÔĶÁ ͼÊé¹Ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡
 
   -> ÍøÂçЭÒé -> httpͨѶ¼°ä¯ÀÀÆ÷ÖеÄHTML±àÂë¡¢URL±àÂë¡¢base64±àÂ뼰תÒå -> ÕýÎÄÔĶÁ

[ÍøÂçЭÒé]httpͨѶ¼°ä¯ÀÀÆ÷ÖеÄHTML±àÂë¡¢URL±àÂë¡¢base64±àÂ뼰תÒå

httpͨѶ¼°ä¯ÀÀÆ÷ÖеÄHTML±àÂë¡¢URL±àÂë¡¢base64±àÂ뼰תÒå

Ŀ¼

httpͨѶ¼°ä¯ÀÀÆ÷ÖеÄHTML±àÂë¡¢URL±àÂë¡¢base64±àÂ뼰תÒå

1¡¢html±àÂëµÄÌØÊâ×Ö·û

1.1¡¢HTML ʵÌå

1.2¡¢HTML×Ö·ûʵÌå,Êý¾ÝµÄ±í´ï

2¡¢URL±àÂëµÄÌØÊâ×Ö·û

2.1¡¢URLÖ§³ÖµÄ×Ö·û ? ? ? ?

2.2¡¢ASCII×Ö·û±àÂë±í

3¡¢Base64±àÂëµÄÌØÊâ×Ö·û

3.1¡¢base64ÔÚhttpºÍhtmlÖÐÓÐÐí¶àʹÓó¡¾°:

3.2¡¢base64×Ö·û±àÂë±í

3.3¡¢base64×Ö½Ú¹æÔò¼°±àÂë²½Öè


1¡¢html±àÂëµÄÌØÊâ×Ö·û

? ? ? ? HTML encoding character

? ? ? ? HTML ºÍ XHTML Óñê×¼µÄ 7 ±ÈÌØ ASCII ´úÂëÔÚÍøÂçÉÏ´«ÊäÊý¾Ý¡£

1.1¡¢HTML ʵÌå

? ? ? ? HTMLÓïÑÔ Öеġ°±£Áô×Ö¡±,¼´Ä³Ð©Ô¤Áô×Ö·û¡£
? ? ? ? ±ÈÈç:²»ÄÜÔÚ³ý¡°ÔªËØ¡±ÒâÍâµÄλÖÃ,ʹÓÃСÓÚºÅ(<)ºÍ´óÓÚºÅ(>),ä¯ÀÀÆ÷»áÎó½âΪËüÃÇÊDZêÇ©¡£
? ? ? ? ÈôÓÐÐèÒªÈÃä¯ÀÀÆ÷ÕýÈ·µØÏÔʾԤÁô×Ö·û,ÎÒÃDZØÐëÔÚ HTML Ô´´úÂëÖÐʹÓÃ×Ö·ûʵÌå(character entities)¡£

1.2¡¢HTML×Ö·ûʵÌå,Êý¾ÝµÄ±í´ï

1¡¢&ºÅ?¡°¼Ó¡± ÌØÊâ×Ö·ûµÄ¡°Ô¼¶¨ÊµÌåÃû³Æ¡±? ¡°¼Ó¡± ;ºÅ,±ÈÈç·ûºÅ:? ?< ,±í´ïΪ:? ? &lt;

×¢Òâ,ʵÌåÃû³Æ:´óСдÃô¸Ð¡£»òÕß:

2¡¢&ºÅ?¡°¼Ó¡± #?¡°¼Ó¡± ÌØÊâ×Ö·ûµÄASCIIÂë? ¡°¼Ó¡± ;ºÅ,±ÈÈç·ûºÅ:? ?< ,±í´ïΪ:? ? &#60;

? ? ? ? html±£Áô×ÖµÄ×Ö·ûʵÌå±í:

ÏÔʾ½á¹ûÃèÊöʵÌåÃû³ÆʵÌå±àºÅ
¿Õ¸ñ&nbsp;&#160;
<СÓÚºÅ&lt;&#60;
>´óÓÚºÅ&gt;&#62;
&ºÍºÅ&amp;&#38;
"ÒýºÅ&quot;&#34;
'ƲºÅ?&apos; (IE²»Ö§³Ö)&#39;
·Ö&cent;&#162;
¡ê°÷&pound;&#163;
£¤ÈÕÔ²&yen;&#165;
Å·Ôª&euro;&#8364;
¡ìС½Ú&sect;&#167;
?°æȨ&copy;&#169;
?×¢²áÉ̱ê&reg;&#174;
?É̱ê&trade;&#8482;
¡Á³ËºÅ&times;&#215;
¡Â³ýºÅ&divide;&#247;

2¡¢URL±àÂëµÄÌØÊâ×Ö·û

? ? ? ? URL encoding?character

2.1¡¢URLÖ§³ÖµÄ×Ö·û ? ? ? ?

? ? ? ? ÓÉÓÚURLÖ»Ö§³ÖÓ¢ÎÄ×Öĸ¡¢Êý×Ö¡¢ºá¸Ü¡¢Ï»®Ïß¡¢¾äµã¡¢²¨ÀËÏß,ÈôÒª±íʾÆäËû×Ö·ûÔòÐèÒª±àÂë¡£
? ? ? ? ÀýÈç:°Ù·ÖºÅ¡¢ÖÐÎÄ¡£
? ? ? ? ÓÉÓÚ°Ù·ÖºÅÒ²ÐèÒª±àÂë,Òò´Ë»á³öÏÖijЩÈƹýÎÊÌâ¡£

¢Ù¡¢URL±àÂë»ùÓÚASCIIÂë:

  • URLÖÐÎÞÌØÊâ×Ö·û: È«ÊÇASCII¿ÉÏÔʾ×Ö·û

https://www.cpuofbs.com/rest/postdata?A=abc&B=123
https://www.cpuofbs.com/rest/postdata?A=abc&B=123

  • URLÖаüº¬ÌØÊâ×Ö·û: ¿Õ¸ñ ¡¢(¶ÙºÅµÈµÈ)

https://www.cpuofbs.com/rest/postdata?A= abc&B¡¢=123
https://www.cpuofbs.com/rest/postdata?A=%20abc&B%E3%80%81=123

  • URLÖаüº¬ÌØÊâ×Ö·û: ÖÐÎÄ

https://www.cpuofbs.com/rest/postdata?ѧÉúÐÕÃû=Ó¢ÎÄÃûabc&Éí·ÝÖ¤ºÅsfzh=432345678909876543
https://www.cpuofbs.com/rest/postdata?%E5%AD%A6%E7%94%9F%E5%A7%93%E5%90%8D=%E8%8B%B1%E6%96%87%E5%90%8Dabc&%E8%BA%AB%E4%BB%BD%E8%AF%81%E5%8F%B7sfzh=432345678909876543
?


¢Ú¡¢ÌØÊâ×Ö·û,Ïȸù¾Ýµ±Ç°Ò³ÃæµÄ±àÂ뷽ʽת»»,±ÈÈç:

<meta charset="utf-8" content-type="text/html" />,

È¡ÆäÊ®Áù½øÖÆÐÎʽ,ÿÁ½Î»Ìí¼Ó1¸ö%

2.2¡¢ASCII×Ö·û±àÂë±í

? ? ? ?HTML ºÍ XHTML Óñê×¼µÄ 7 ±ÈÌØ ASCII ´úÂëÔÚÍøÂçÉÏ´«ÊäÊý¾Ý¡£

2.2.1¡¢¡°32~126¡±Çø¶Î,¿ÉÏÔʽÇø¶Î:

½á¹ûÃèÊöʵÌå±àºÅ
space&#32;
!exclamation mark&#33;
"quotation mark&#34;
#number sign&#35;
$dollar sign&#36;
%percent sign&#37;
&ampersand&#38;
'apostrophe&#39;
(left parenthesis&#40;
)right parenthesis&#41;
*asterisk&#42;
+plus sign&#43;
,comma&#44;
-hyphen&#45;
.period&#46;
/slash&#47;
0digit 0&#48;
1digit 1&#49;
2digit 2&#50;
3digit 3&#51;
4digit 4&#52;
5digit 5&#53;
6digit 6&#54;
7digit 7&#55;
8digit 8&#56;
9digit 9&#57;
:colon&#58;
;semicolon&#59;
<less-than&#60;
=equals-to&#61;
>greater-than&#62;
?question mark&#63;
@at sign&#64;
Auppercase A&#65;
Buppercase B&#66;
Cuppercase C&#67;
Duppercase D&#68;
Euppercase E&#69;
Fuppercase F&#70;
Guppercase G&#71;
Huppercase H&#72;
Iuppercase I&#73;
Juppercase J&#74;
Kuppercase K&#75;
Luppercase L&#76;
Muppercase M&#77;
Nuppercase N&#78;
Ouppercase O&#79;
Puppercase P&#80;
Quppercase Q&#81;
Ruppercase R&#82;
Suppercase S&#83;
Tuppercase T&#84;
Uuppercase U&#85;
Vuppercase V&#86;
Wuppercase W&#87;
Xuppercase X&#88;
Yuppercase Y&#89;
Zuppercase Z&#90;
[left square bracket&#91;
\backslash&#92;
]right square bracket&#93;
^caret&#94;
_underscore&#95;
`grave accent&#96;
alowercase a&#97;
blowercase b&#98;
clowercase c&#99;
dlowercase d&#100;
elowercase e&#101;
flowercase f&#102;
glowercase g&#103;
hlowercase h&#104;
ilowercase i&#105;
jlowercase j&#106;
klowercase k&#107;
llowercase l&#108;
mlowercase m&#109;
nlowercase n&#110;
olowercase o&#111;
plowercase p&#112;
qlowercase q&#113;
rlowercase r&#114;
slowercase s&#115;
tlowercase t&#116;
ulowercase u&#117;
vlowercase v&#118;
wlowercase w&#119;
xlowercase x&#120;
ylowercase y&#121;
zlowercase z&#122;
{left curly brace&#123;
|vertical bar&#124;
}right curly brace&#125;
~tilde&#126;

2.2.2¡¢¡°0~30¼°¶ÀÁ¢µÄ127¡±Çø¶Î,É豸¿ØÖÆÇø¶Î:

? ? ? ?ASCIIÉ豸¿ØÖÆ´úÂë×î³õ±»Éè¼ÆΪÓÃÀ´¿ØÖÆÖîÈç´òÓ¡»úºÍ´Å´øÇý¶¯Æ÷Ö®ÀàµÄÓ²¼þÉ豸¡£ÔÚHTMLÎĵµÖÐÕâЩ´úÂë²»»áÆðÈκÎ×÷ÓÃ:

½á¹ûÃèÊöʵÌå±àºÅ
NULnull character&#00;
SOHstart of header&#01;
STXstart of text&#02;
ETXend of text&#03;
EOTend of transmission&#04;
ENQenquiry&#05;
ACKacknowledge&#06;
BELbell (ring)&#07;
BSbackspace&#08;
HThorizontal tab&#09;
LFline feed&#10;
VTvertical tab&#11;
FFform feed&#12;
CRcarriage return&#13;
SOshift out&#14;
SIshift in&#15;
DLEdata link escape&#16;
DC1device control 1&#17;
DC2device control 2&#18;
DC3device control 3&#19;
DC4device control 4&#20;
NAKnegative acknowledge&#21;
SYNsynchronize&#22;
ETBend transmission block&#23;
CANcancel&#24;
EMend of medium&#25;
SUBsubstitute&#26;
ESCescape&#27;
FSfile separator&#28;
GSgroup separator&#29;
RSrecord separator&#30;
USunit separator&#31;
DELdelete (rubout)&#127;

3¡¢Base64±àÂëµÄÌØÊâ×Ö·û

? ? ? ? Base64 encoding character

3.1¡¢base64ÔÚhttpºÍhtmlÖÐÓÐÐí¶àʹÓó¡¾°:

1¡¢±ÈÈçÎÒÃÇÔÚhtmlÖбí´ï1¸öͼƬÎļþ½øÐÐbase64±àÂëµÄsrc×ÊÔ´,¿ÉÒÔ:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==

?2¡¢ÔÙ±ÈÈç?¶ÔÎļþ½øÐÐbase64±àÂë,ÎÒÃÇÉÏ´«ºÍÏÂÔس¬´óÎļþ,¿ÉÏȶÔÆä½øÐÐbase64¶þ½øÖƱàÂëÔÙѹËõºó,½øÐÐ,ÕâÑù¿ÉÒÔ¼«´óÌáÉýЧÂʲ¢ÌṩÁË¡°¶Ïµã¡±Ðø´«µÄ¿ÉÄÜ

? ? ? ? °¸Àý:delphiѹËõºóʹÓÃhttpЭÒébase64ÉÏ´«ÏÂÔØ6G³¬´óÎļþ_pulledupµÄ²©¿Í-CSDN²©¿ÍdelphiѹËõºóʹÓÃhttpЭÒébase64ÉÏ´«ÏÂÔØ6G³¬´óÎļþ×¢:·þÎñ¶ËÈí¼þ,ʹÓøßÓ³öÆ·GYRestServerϵÁС£»¶Ó­Ê¹ÓÃ,¼ÓQQȺ×Éѯ:174483085Ò»¡¢ÖªÊ¶µã:1¡¢Delphi×Ô´øµÄѹËõ½âѹµ¥Ôªsystem.zlib.pasÖкËÐĺ¯ÊýµÄʹÓÃ2¡¢·þÎñ¶ËhttpЭÒéContentType(mime-type)Ïà¹ØÁбíÀàÐ͵Ä×¢²á3¡¢Base64±àÂëµÄ¹æÔò4¡¢ÎªºÎÒª·Ö¿é¶ÏµãÐø´«,²¢Ê¹ÓÃTFileStreamÎļþÁ÷Ìæ´úÄÚ´æÁ÷TMemoryStream5¡¢Buffe..https://blog.csdn.net/pulledup/article/details/121455926

3.2¡¢base64×Ö·û±àÂë±í

base64_°Ù¶È°Ù¿ÆBase64ÊÇÍøÂçÉÏ×î³£¼ûµÄÓÃÓÚ´«Êä8Bit×Ö½ÚÂëµÄ±àÂ뷽ʽ֮һ,Base64¾ÍÊÇÒ»ÖÖ»ùÓÚ64¸ö¿É´òÓ¡×Ö·ûÀ´±íʾ¶þ½øÖÆÊý¾ÝµÄ·½·¨¡£¿É²é¿´RFC2045~RFC2049,ÉÏÃæÓÐMIMEµÄÏêϸ¹æ·¶¡£Base64±àÂëÊÇ´Ó¶þ½øÖƵ½×Ö·ûµÄ¹ý³Ì,¿ÉÓÃÓÚÔÚHTTP»·¾³Ï´«µÝ½Ï³¤µÄ±êʶÐÅÏ¢¡£²ÉÓÃBase64±àÂë¾ßÓв»¿É¶ÁÐÔ,ÐèÒª½âÂëºó²ÅÄÜÔĶÁ¡£Base64ÓÉÓÚÒÔÉÏÓŵ㱻¹ã·ºÓ¦ÓÃÓÚ¼ÆËã»úµÄ¸÷¸öÁìÓò,È»¶øÓÉÓÚÊä³öÄÚÈÝÖаüÀ¨Á½¸öÒÔÉÏ¡°·ûºÅÀࡱ×Ö·û(+, /, =),²»Í¬µÄÓ¦Óó¡¾°ÓÖ·Ö±ðÑÐÖÆÁËBase64µÄ¸÷ÖÖ¡°±äÖÖ¡±¡£ÎªÍ³Ò»ºÍ¹æ·¶»¯Base64µÄÊä³ö,Base62x±»ÊÓΪÎÞ·ûºÅ»¯µÄ¸Ä½ø°æ±¾¡£https://baike.baidu.com/item/base64/8545775?fr=aladdin

? ? ? ? ´óдA~Z ,Сдa~z ,?Êý×Ö0~9, +? \? ,ÒÔ¼°1¸öÌØÊâµÄ¡°×Ö·ûA¡±½áβ±êʶ·û ==?

6λ¶þ½øÖƲ¹ÆëºóµÄ10½øÖÆË÷Òý
base64
×Ö·û
6λ¶þ½øÖƲ¹ÆëºóµÄ10½øÖÆË÷Òýbase64×Ö·û6λ¶þ½øÖƲ¹ÆëºóµÄ10½øÖÆË÷Òýbase64×Ö·û6λ¶þ½øÖƲ¹ÆëºóµÄ10½øÖÆË÷Òý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
/

base64×Ö·ûË÷Òý¡¢¶þ½øÖÆ¡¢base64×Ö·û?¶ÔÕÕ±í:

Ë÷Òý2½øÖÆCharË÷Òý2½øÖÆCharË÷Òý2½øÖÆCharË÷Òý2½øÖÆChar
0000000A16010000Q32100000g48110000w
1000001B17010001R33100001h49110001x
2000010C18010010S34100010i50110010y
3000011D19010011T35100011j51110011z
4000100E20010100U36100100k521101000
5000101F21010101V37100101l531101011
6000110G22010110W38100110m541101102
7000111H23010111X39100111n551101113
8001000I24011000Y40101000o561110004
9001001J25011001Z41101001p571110015
10001010K26011010a42101010q581110106
11001011L27011011b43101011r591110117
12001100M28011100c44101100s601111008
13001101N29011101d45101101t611111019
14001110O30011110e46101110u62111110+
15001111P31011111f47101111v63111111/

Padding

Ìî³äλ

=

?´úÂë±íʾBase64×Ö·û±í:

Shotgun.Js.Base64 = {
    _table: [
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
        'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
    ],

3.3¡¢base64×Ö½Ú¹æÔò¼°±àÂë²½Öè

3.3.1¡¢·Çbase64µÄ×Ö·ûÄÚ´æ±à×鷽ʽ

? ? ? ? ͨ³£,¼ÆËã»úµÄÄÚ´æÖÐÓÃ8λ¶þ½øÖƱí´ï1¸ö×Ö·û¡£

? ? ? ? ±ÈÈç×Ö·ûA :0100 0001 :

01000001

3.3.2¡¢base64µÄ×Ö·ûÄÚ´æ±à×鷽ʽ

? ? ? ? ½«Ô­±¾1*8=8,¸Ä±àΪ2*(2²¹Æë+6)=16??

? ? ? ? ±ÈÈç×Ö·ûA :

00010000 00010000

²éÕÒASCII±í10½øÖƽá¹û:

16 16

»ò(±ê×¼¸ñʽ):

00010000 00010000 00000000 00000000

16 16?NUL(null)?NUL(null)

? ? ? ? È»ºó,±ÈÕÕbase64×Ö·û±àÂë±í:

16 16

½á¹û:

QQ

»ò(±ê×¼¸ñʽ):

16 16?NUL(null)?NUL(null)? ---------00000000 00000000¸ÕºÃ±È¶Ô³ö2¸ö¡°A¡±ÔòÓÃ==±íʾ:

QQ==

3.3.3¡¢jsÖÐbase64µÄ±àÂëºÍ½âÂë:

// ½â¾ö·½°¸ #1 ¨C ÔÚ±àÂë֮ǰתÒå×Ö·û´®---unescapeºÍescapeÒÑÆúÓà  :
function utf8_to_b64(str) {
    return window.btoa(unescape(encodeURIComponent(str)));
}; //
function b64_to_utf8(str) {
    return decodeURIComponent(escape(window.atob(str)));
}; //
const bin8 = '01000001', // 00010000 00010000
    bin16 = '0001000000010000', // 00010000 00010000  ´ú±íQQ
    bin32 = '00010000000100000000000000000000'; // 00010000 00010000 00000000 00000000  ´ú±íQQ==
//
//00010000 00010000
let encodedData = window.btoa("A"); // = Base64±àÂë (ȱÏÝ)
console.log(encodedData); //: QQ==
let decodedData = window.atob("QQ=="); // = ASCII±àÂë (ȱÏÝ)
let decodedData_2 = window.atob("QQ=="); // = ASCII±àÂë (ȱÏÝ)
console.log(decodedData); //: 
console.log(utf8_to_b64("A")); //: (ȱÏÝ)
console.log(b64_to_utf8("QQ==")); //: ±ØÐë2**nÃÝµÈ //console.log(2 ** 4);//: 2**nÃÝÔËËã
console.log(b64_to_utf8("QQ")); //: (ȱÏÝ)
//
//½â¾ö·½°¸ #2 ¨C ÖØдatob()ºÍbtoa()ʹÓÃTypedArrays ºÍ UTF-8 : 
//×¢Òâ:ÒÔÏ´úÂë¶ÔÓÚ´Ó Base64 ×Ö·û´®»ñÈ¡ArrayBufferÒ²ºÜÓÐÓÃ,·´Ö®ÒàÈ»(¼ûÏÂÎÄ): 
//
"use strict";
// ×Ö½ÚÊý×éµ½Base64×Ö·û´®½âÂë :  
function b64ToUint6(nChr) {
    return nChr > 64 && nChr < 91 ?
        nChr - 65 :
        nChr > 96 && nChr < 123 ?
        nChr - 71 :
        nChr > 47 && nChr < 58 ?
        nChr + 4 :
        nChr === 43 ?
        62 :
        nChr === 47 ?
        63 :
        0;
}

function base64DecToArr(sBase64, nBlocksSize) {
    const sB64Enc = sBase64.replace(/[^A-Za-z0-9+/]/g, "");
    const nInLen = sB64Enc.length;
    const nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2;
    const taBytes = new Uint8Array(nOutLen);

    let nMod3;
    let nMod4;
    let nUint24 = 0;
    let nOutIdx = 0; //let nOutId = 0;
    for (let nInIdx = 0; nInIdx < nInLen; nInIdx++) {
        nMod4 = nInIdx & 3;
        nUint24 |= b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 6 * (3 - nMod4);
        if (nMod4 === 3 || nInLen - nInIdx === 1) {
            nMod3 = 0;
            while (nMod3 < 3 && nOutIdx < nOutLen) {
                taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;
                nMod3++;
                nOutIdx++;
            }
            nUint24 = 0;

        }
    }

    return taBytes;
}

/* Base64×Ö·û´®µ½Êý×é±àÂë :   */
function uint6ToB64(nUint6) {
    return nUint6 < 26 ?
        nUint6 + 65 :
        nUint6 < 52 ?
        nUint6 + 71 :
        nUint6 < 62 ?
        nUint6 - 4 :
        nUint6 === 62 ?
        43 :
        nUint6 === 63 ?
        47 :
        65;
}

function base64EncArr(aBytes) {
    let nMod3 = 2;
    let sB64Enc = "";

    const nLen = aBytes.length;
    let nUint24 = 0;
    for (let nIdx = 0; nIdx < nLen; nIdx++) {
        nMod3 = nIdx % 3;
        if (nIdx > 0 && (nIdx * 4 / 3) % 76 === 0) {
            sB64Enc += "\r\n";
        }

        nUint24 |= aBytes[nIdx] << (16 >>> nMod3 & 24);
        if (nMod3 === 2 || aBytes.length - nIdx === 1) {
            sB64Enc += String.fromCodePoint(uint6ToB64(nUint24 >>> 18 & 63), uint6ToB64(nUint24 >>> 12 & 63), uint6ToB64(nUint24 >>> 6 & 63), uint6ToB64(nUint24 & 63));
            nUint24 = 0;
        }
    }
    return sB64Enc.substr(0, sB64Enc.length - 2 + nMod3) + (nMod3 === 2 ? '' : nMod3 === 1 ? '=' : '==');
}

/* UTF-8Êý×éµ½JS×Ö·û´®,·´Ö®ÒàÈ» :   */

function UTF8ArrToStr(aBytes) {
    let sView = "";
    let nPart;
    const nLen = aBytes.length;
    for (let nIdx = 0; nIdx < nLen; nIdx++) {
        nPart = aBytes[nIdx];
        sView += String.fromCodePoint(
            nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
            /* (nPart - 252 << 30) may be not so safe in ECMAScript! So¡­: */
            (nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128 :
            nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */
            (nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128 :
            nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */
            (nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128 :
            nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */
            (nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128 :
            nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */
            (nPart - 192 << 6) + aBytes[++nIdx] - 128 :
            /* nPart < 127 ? */
            /* one byte */
            nPart
        );
    }
    return sView;
}

function strToUTF8Arr(sDOMStr) {
    let aBytes;
    let nChr;
    const nStrLen = sDOMStr.length;
    let nArrLen = 0;

    /* mapping¡­ */
    for (let nMapIdx = 0; nMapIdx < nStrLen; nMapIdx++) {
        nChr = sDOMStr.codePointAt(nMapIdx);

        if (nChr > 65536) {
            nMapIdx++;
        }

        nArrLen += nChr < 0x80 ? 1 : nChr < 0x800 ? 2 : nChr < 0x10000 ? 3 : nChr < 0x200000 ? 4 : nChr < 0x4000000 ? 5 : 6;
    }

    aBytes = new Uint8Array(nArrLen);

    /* ת¼ : transcription¡­ */
    let nIdx = 0;
    let nChrIdx = 0;
    while (nIdx < nArrLen) {
        nChr = sDOMStr.codePointAt(nChrIdx);
        if (nChr < 128) {
            /* one byte */
            aBytes[nIdx++] = nChr;
        } else if (nChr < 0x800) {
            /* two bytes */
            aBytes[nIdx++] = 192 + (nChr >>> 6);
            aBytes[nIdx++] = 128 + (nChr & 63);
        } else if (nChr < 0x10000) {
            /* three bytes */
            aBytes[nIdx++] = 224 + (nChr >>> 12);
            aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);
            aBytes[nIdx++] = 128 + (nChr & 63);
        } else if (nChr < 0x200000) {
            /* four bytes */
            aBytes[nIdx++] = 240 + (nChr >>> 18);
            aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);
            aBytes[nIdx++] = 128 + (nChr & 63);
            nChrIdx++;
        } else if (nChr < 0x4000000) {
            /* five bytes */
            aBytes[nIdx++] = 248 + (nChr >>> 24);
            aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);
            aBytes[nIdx++] = 128 + (nChr & 63);
            nChrIdx++;
        } else /* if (nChr <= 0x7fffffff) */ {
            /* six bytes */
            aBytes[nIdx++] = 252 + (nChr >>> 30);
            aBytes[nIdx++] = 128 + (nChr >>> 24 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);
            aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);
            aBytes[nIdx++] = 128 + (nChr & 63);
            nChrIdx++;
        }
        nChrIdx++;
    }

    return aBytes;
}
// ²âÊÔ : 
const sMyInput = "Base 64 \u2014 ";
const aMyUTF8Input = strToUTF8Arr(sMyInput);
const sMyBase64 = base64EncArr(aMyUTF8Input);
console.log(sMyBase64);
//
const aMyUTF8Output = base64DecToArr(sMyBase64);
const sMyOutput = UTF8ArrToStr(aMyUTF8Output);
console.log(sMyOutput);
//
const sMyInput_ = "\ud869\ude95\u3400\u499b\u2a6c7\udec7";
const aMyUTF8Input_ = strToUTF8Arr(sMyInput);
const sMyBase64_ = base64EncArr(aMyUTF8Input);
console.log(sMyBase64_);
// 👪 \ תÒå·û: (€) &#8364; &#x20AC; &lt; &#60; &amp;(&) (") ±íʾΪ&quot; ½«µ¥ÒýºÅ (') ±íʾΪ&apos; 
//&#x1F468&#x200D&#x1F469&#x200D&#x1F467&#x200D&#x1F466ΪÁ˱í´ï'\u1F468\u200D\u1F469\u200D\u1F467\u200D\u1F466'ʹÓÃ16½øÖÆ»ò10½øÖÆ
//&#xd869&#xde95&#x3400&#x499b&#x2a6c7&#xdec7
//&#x2A6C7; ; &#x233B4; ¹ØÓÚUTF-16²¹³ä×Ö·ûÓëÂëµã :ʹÓÃUCS4¸ßµÍλת»»¼ÆËãºóµÄÂëµã"&#x233B4;"¶ø²»ÊÇUTF-16µÄ¸ßµÍλÂë: &#xD84C;&#xDFB4;
//
// ½« Base64 ×Ö·û´®½âÂëΪ Uint8Array »ò ArrayBuffer : 
//º¯Êýbase64DecToArr(sBase64[, nBlockSize])·µ»ØÒ»¸öuint8×Ö½ÚÊý×é¡£
//Èç¹ûÄúµÄÄ¿±êÊǹ¹½¨16λ/32λ/64λԭʼÊý¾ÝµÄ»º³åÇø,ÇëʹÓÃnBlockSize²ÎÊý(ÃݵȲÎÊý) : ÕâÊÇuint8Array.bufferËù°üº¬µÄ×Ö½ÚÊý :
//uint8Array.buffer.bytesLengthÊôÐÔ: 
//1¡¢ASCII¶þ½øÖÆ×Ö·û(¼´×Ö·û´®ÖеÄÿ¸ö×Ö·û¶¼±»ÊÓΪ¶þ½øÖÆÊý¾Ý8λ1¸ö×Ö½ÚµÄ×Ö·û)
//2¡¢»òUTF-8±àÂë×Ö·û´®Îª1¸ö8λ,UTF-16×Ö·û´®Îª2¸ö8λ,UTF-32×Ö·û´®Îª4¸ö8λ¡£
// : ×Ö·û±àÂë : 
//
// "Base 64 \u2014 Mozilla Developer Network"
const myArray = base64DecToArr("QmFzZSA2NCDigJQgTW96aWxsYSBEZXZlbG9wZXIgTmV0d29yaw==");
// "Base 64 \u2014 " // : \u2014×Ö½Ú³¤3 : \uÕ¼1¸ö×Ö½Ú¡¢È«½Ç×Ö·û-Õ¼2¸ö×Ö½Ú
const myBuffer = base64DecToArr("QmFzZSA2NCDigJQgTW96aWxsYSBEZXZlbG9wZXIgTmV0d29yaw==").buffer;
console.log(myBuffer.byteLength); //:
//µ±Äú´Ó·þÎñÆ÷¼ìË÷ÎĵµÊ±,·þÎñÆ÷ͨ³£»áËæÎĵµ·¢ËÍһЩ¸½¼ÓÐÅÏ¢¡£Õâ³ÆΪ HTTP ±êÍ·¡£ÕâÊÇÒ»¸ö¹ØÓÚÎĵµÐÅÏ¢µÄʾÀý,¸ÃÐÅϢͨ¹ý HTTP ±êÍ·ÓëÎĵµÒ»Æð´Ó·þÎñÆ÷´«Êäµ½¿Í»§¶Ëʱ´«µÝ


  ÍøÂçЭÒé ×îÐÂÎÄÕÂ
ʹÓÃEasyswoole ´î½¨¼òµ¥µÄWebsoket·þÎñ
³£¼ûµÄÊý¾ÝͨÐÅ·½Ê½ÓÐÄÄЩ£¿
Openssl 1024bit RSAËã·¨---¹«Ë½Ô¿»ñÈ¡ºÍ´¦
HTTPSЭÒéµÄÃÜÔ¿½»»»Á÷³Ì
¡¶Ð¡°×WEB°²È«ÈëÃÅ¡·03. ©¶´Æª
HttpRunner4.x °²×°ÓëʹÓÃ
2021-07-04
ÊÖдRPCѧϰ±Ê¼Ç
K8S¸ß¿ÉÓð汾²¿Êð
mySQL¼ÆËãIPµØÖ··¶Î§
ÉÏһƪÎÄÕ      ÏÂһƪÎÄÕ      ²é¿´ËùÓÐÎÄÕÂ
¼Ó:2022-08-19 19:37:39  ¸ü:2022-08-19 19:39:32 
 
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡

360ͼÊé¹Ý ¹ºÎï Èý·á¿Æ¼¼ ÔĶÁÍø ÈÕÀú ÍòÄêÀú 2024Äê11ÈÕÀú -2024/11/25 22:53:42-

ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
  ÍøÕ¾ÁªÏµ: qq:121756557 email:121756557@qq.com  ITÊýÂë