Hướng dẫn what is base64 encoding in php? - mã hóa base64 trong php là gì?

[Php 4, Php 5, Php 7, Php 8]

Base64_encode - Mã hóa dữ liệu với MIME Base64Encodes data with MIME base64

Sự mô tả

base64_encode [Chuỗi $string]: Chuỗi[string $string]: string

Mã hóa này được thiết kế để làm cho dữ liệu nhị phân tồn tại vận chuyển thông qua các lớp vận chuyển không sạch 8 bit, chẳng hạn như các thân thư.

Dữ liệu được mã hóa Base64 mất khoảng 33% so với dữ liệu gốc.

Thông số

string

Dữ liệu để mã hóa.

Trả về giá trị

Dữ liệu được mã hóa, như một chuỗi.

Ví dụ

Ví dụ #1 base64_encode [] Ví dụbase64_encode[] example

Ví dụ trên sẽ xuất ra:

VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==

Xem thêm

  • base64_decode [] - Giải mã dữ liệu được mã hóa bằng mime base64
  • Chunk_split [] - Chia một chuỗi thành các khối nhỏ hơn
  • convert_uuencode [] - uuencode một chuỗi
  • »& NBSP; RFC 2045 Phần 6.8

Gutzmer tại USA DOT NET

11 năm trước

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions:

Rasmus Schultz ¶

4 năm trước

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}

$string0

$string1

$string2

$string3

Biziclop tại Vipmail Dot Hu

5 năm trước

$string4

$string5

$string6

$string7

Mitmacher ¶

13 năm trước

$string8

$string9

string0

string1

string2

Hayley Watson ¶

9 năm trước

string3

string4

string5

string6

$string3

Luke tại lukeoliff.com

11 năm trước

string8

string9

0

1

2

3

$string3

Rasmus Schultz ¶

4 năm trước

5

6

7

$string3

Biziclop tại Vipmail Dot Hu

5 năm trước

9

Mitmacher ¶

13 năm trước

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 0

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 1

$string3

Hayley Watson ¶

9 năm trước

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 3

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 4

$string6

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 6

Luke tại lukeoliff.com

Massimo Dot Scamarcia tại Gmail Dot Com ¶

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 7

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 8

For anyone interested in the 'base64url' variant encoding, you can use this pair of functions: 9

0

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

1

$string3

Rasmus Schultz ¶

4 năm trước

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

3

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

4

$string3

Biziclop tại Vipmail Dot Hu

13 năm trước

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

6

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

7

$string3

Rasmus Schultz ¶

4 năm trước

base64url_decode[$data] {
  return
base64_decode[str_pad[strtr[$data, '-_', '+/'], strlen[$data] % 4, '=', STR_PAD_RIGHT]];
}
?>

9

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:0

$string3

Biziclop tại Vipmail Dot Hu

5 năm trước

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:2

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:3

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:4

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:5

$string3

Mitmacher ¶

4 năm trước

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:7

Biziclop tại Vipmail Dot Hu

5 năm trước

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:8

In PHP 7, the padding issue with base64_decode[] is no more - the following is totally fine:9

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
0

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
1

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
2

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
3

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
4

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
5

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
6

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
7

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
8

function base64_encode_url[$string] {
    return str_replace[['+','/','='], ['-','_',''], base64_encode[$string]];
}
9

$string00

$string01

$string02

$string3

Mitmacher ¶

13 năm trước

$string04

$string05

$string06

$string07

Hayley Watson ¶

4 năm trước

$string08

$string09

$string10

$string11

$string12

$string3

Biziclop tại Vipmail Dot Hu

13 năm trước

$string14

Hayley Watson ¶

9 năm trước

$string15

$string16

$string17

Luke tại lukeoliff.com

5 năm trước

$string18

$string19

$string6

$string21

Mitmacher ¶

4 năm trước

$string22

$string23

$string3

Biziclop tại Vipmail Dot Hu

5 năm trước

$string25

$string26

Bài Viết Liên Quan

Chủ Đề