Skip to content

Instantly share code, notes, and snippets.

@NimzyMaina
Last active January 10, 2018 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NimzyMaina/5dc2555058d3955849533c9d3c4c43ce to your computer and use it in GitHub Desktop.
Save NimzyMaina/5dc2555058d3955849533c9d3c4c43ce to your computer and use it in GitHub Desktop.
Encrypt and Decrypt MYSQL
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');
@NimzyMaina
Copy link
Author

MySQL Crypt

This sample code is used to store and retrieve encrypted data from a MySQL database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment