Last active
January 10, 2018 14:45
-
-
Save NimzyMaina/5dc2555058d3955849533c9d3c4c43ce to your computer and use it in GitHub Desktop.
Encrypt and Decrypt MYSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `test` ( | |
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
`name` VARBINARY(100) NULL | |
PRIMARY KEY (`id`)) | |
ENGINE = InnoDB | |
DEFAULT CHARACTER SET = utf8 | |
COLLATE = utf8_general_ci; | |
INSERT INTO test (name) | |
VALUE (AES_ENCRYPT('valuegoeshere','secretkeygoeshere')); | |
SELECT AES_DECRYPT(name,'secretkeygoeshere') AS name_decrypt | |
FROM test; | |
SELECT id, AES_DECRYPT(name,'secretkeygoeshere') AS name_decrypt | |
FROM test | |
where name = AES_ENCRYPT('valuegoeshere','secretkeygoeshere'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MySQL Crypt
This sample code is used to store and retrieve encrypted data from a MySQL database.