SQL | ENCRYPT Function Last Updated : 31 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The SQL Encrypt function is used to encrypt a string using UNIX crypt(). The function is based on Unix crypt() system call, hence it returns NULL on Windows systems. The Encrypt function accepts two parameters which are the string and the salt to be encrypted. The Encrypt function returns a binary string. Syntax: ENCRYPT(string, salt) Parameters Used: string - It is used to specify the plain text string that is to be encrypted using UNIX crypt(). salt - It is used to specify a string that is at least 2 characters long and cab be used in the encryption process. If salt is not provided, the ENCRYPT function uses a random value. Return Value: The Encrypt function in SQL returns a binary string. The Encrypt function returns null in the following cases: If salt is less than 2 characters in length, then the Encrypt function returns NULL. If the string is NULL, then the Encrypt function returns NULL. If UNIX crypt() is not available on the system, then the Encrypt function returns NULL. Supported Versions of MySQL: MySQL 5.7 MySQL 5.6 MySQL 5.5 MySQL 5.1 MySQL 5.0 MySQL 4.1 Example-1: Implementing Encrypt function on a string. SELECT ENCRYPT('xyz'); Output: sf3Le/pz2ApNY Example-2: Implementing Encrypt function on a bigger string. SELECT ENCRYPT('geeksforgeeks'); Output: .mblNS3yOZxb2 Example-3: Implementing Encrypt function on a string by passing both the arguments. SELECT ENCRYPT('geeksforgeeks', '123'); Output: 12SrVMQf0pwFU Example-4: Implementing Encrypt function on a string by passing less than 2 characters in the salt argument. SELECT ENCRYPT('geeksforgeeks', '2'); Output: NULL Since the salt argument is less than 2 characters in length, the Encrypt function returns NULL. Example-5: Implementing Encrypt function on a NULL string. SELECT ENCRYPT(NULL); Output: NULL Comment More infoAdvertise with us Next Article SQL | ENCRYPT Function S Shubrodeep Banerjee Follow Improve Article Tags : SQL SQLmysql SQL-Functions Similar Reads MySQL | AES_ENCRYPT ( ) Function The MySQL AES_ENCRYPT function is used for encrypting a string using Advanced Encryption Standard (AES) algorithm. The MySQL AES_ENCRYPT function encodes the data with 128 bits key length but it can be extended up to 256 bits key length. It encrypts a string and returns a binary string. The value re 1 min read MySQL | DES_ENCRYPT ( ) Function In todayâs world, keeping data safe is important for any database. MySQL, one of the most popular database systems, offers various tools to secure your information. Among these is the DES_ENCRYPT() function, which uses the Data Encryption Standard (DES) algorithm to encrypt your data. This function 3 min read MySQL | AES_DECRYPT ( ) Function The MySQL AES_DECRYPT function returns the original string after decrypting an encrypted string. It uses AES(Advanced Encryption Standard) algorithm to perform the decryption. The AES_DECRYPT function returns the decrypted string or NULL if it detects invalid data. The value returned by the AES_DECR 1 min read PLSQL | DECOMPOSE Function The DECOMPOSE Function in PLSQL is used for accepting a string and returning its Unicode string. The DECOMPOSE Function is generally the opposite of the COMPOSE function. The DECOMPOSE function is valid only for Unicode characters and it returns a Unicode string after decomposition in the same chara 1 min read ELT() Function in MySQL In this article, we are going to cover ELT function with examples. In ELT function, number field will state that how many strings will be there. ELT function in MySQL is used to returns the string which is at index number specified in the argument list. In this function there is number field and str 1 min read Like