Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of data Compression, encryption and decryption in PHP

Shulou Source: shulou.com Published: 2022-06-03 19:36:32 10月12日 Update

Editor to share with you the PHP data compression, encryption and decryption example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Data exchange is often needed in network communication and file storage. in order to reduce network communication traffic, file storage size and encryption communication rules, two-way encryption and decryption of data is often needed to ensure data security.

The main functions needed to realize this function in PHP are pack and unpack functions.

Pack

Compress the data into the string.

Syntax: string pack (string format, mixed [args]...)

Return value: string

This function is used to compress and package the data into a string.

A-NUL- string fill [padded string] fill the string white space with NULL characters

Fill the A-SPACE- string with [padded string]

H-hexadecimal string, low "quad" [low nibble first] (low first)

H-hexadecimal string, high "quad" [high nibble first] (high order comes first)

C-characters with symbols

C-unsigned characters

S-signed short pattern [short] (usually 16 bits, in machine byte order)

S-unsigned short pattern [short] (usually 16 bits, sorted by machine bytes)

N-unsigned short pattern [short] (usually 16 bits, sorted by large endian bytes)

V-unsigned short pattern [short] (usually 16 bits, sorted by small endian bytes)

I-signed integers (determined by size and byte order)

I-unsigned integers (determined by size and byte order)

L-signed long pattern [long] (usually 32 bits, in machine byte order)

L-unsigned long pattern [long] (usually 32 bits, in machine byte order)

N-unsigned long pattern [long] (usually 32 bits, in large edian byte order)

V-unsigned long pattern [long] (usually 32 bits, in small edian byte order)

F-floating point (determined by size and byte order)

D-double precision (determined by size and byte order)

X-Null bytes [NUL byte]

X-the next byte [Back up one byte] (rewind one bit)

Unpack

Extract the compressed bit string data.

Syntax: string pack (string format, mixed [args]...)

Return value: array

This function is used to decompress the data of the bit string. This function is exactly the same as the function of the same name as Perl.

Case 1. Pack implements reducing the size of file data storage

Tags: Storage characters files data strings bytes size symbols patterns order integers functions encryption binary location format length communication machine case Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia Apple Redmi OPPO Reno