Encryption and Compression Functions
954
•
COMPRESS(string_to_compress)
[954]
Compresses a string and returns the result as a binary string. This function requires MySQL to have
been compiled with a compression library such as
zlib
. Otherwise, the return value is always
NULL
.
The compressed string can be uncompressed with
UNCOMPRESS()
[957]
.
mysql>
SELECT LENGTH(COMPRESS(REPEAT('a',1000)));
-> 21
mysql>
SELECT LENGTH(COMPRESS(''));
-> 0
mysql>
SELECT LENGTH(COMPRESS('a'));
-> 13
mysql>
SELECT LENGTH(COMPRESS(REPEAT('a',16)));
-> 15
The compressed string contents are stored the following way:
• Empty strings are stored as empty strings.
• Nonempty strings are stored as a 4-byte length of the uncompressed string (low byte first),
followed by the compressed string. If the string ends with space, an extra “
.
” character is added
to avoid problems with endspace trimming should the result be stored in a
CHAR
or
VARCHAR
column. (However, use of nonbinary string data types such as
CHAR
or
VARCHAR
to store
compressed strings is not recommended anyway because character set conversion may occur.
Use a
VARBINARY
or
BLOB
binary string column instead.)
•
DECODE(crypt_str,pass_str)
[954]
Decrypts the encrypted string
crypt_str
using
pass_str
as the password.
crypt_str
should be
a string returned from
ENCODE()
[955]
.
•
DES_DECRYPT(crypt_str[,key_str])
[954]
Decrypts a string encrypted with
DES_ENCRYPT()
[954]
. If an error occurs, this function returns
NULL
.
This function works only if MySQL has been configured with SSL support. See
Section 6.3.6, “Using
SSL for Secure Connections”
.
If no
key_str
argument is given,
DES_DECRYPT()
[954]
examines the first byte of the encrypted
string to determine the DES key number that was used to encrypt the original string, and then reads
the key from the DES key file to decrypt the message. For this to work, the user must have the
SUPER
[578]
privilege. The key file can be specified with the
--des-key-file
[407]
server option.
If you pass this function a
key_str
argument, that string is used as the key for decrypting the
message.
If the
crypt_str
argument does not appear to be an encrypted string, MySQL returns the given
crypt_str
.
•
DES_ENCRYPT(str[,{key_num|key_str}])
[954]
Encrypts the string with the given key using the Triple-DES algorithm.
This function works only if MySQL has been configured with SSL support. See
Section 6.3.6, “Using
SSL for Secure Connections”
.
The encryption key to use is chosen based on the second argument to
DES_ENCRYPT()
[954]
,
if one was given. With no argument, the first key from the DES key file is used. With a
key_num
argument, the given key number (0 to 9) from the DES key file is used. With a
key_str
argument,
the given key string is used to encrypt
str
.
The key file can be specified with the
--des-key-file
[407]
server option.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...