Skip to content

Instantly share code, notes, and snippets.

@xtrasmal
Last active September 17, 2016 20:54
Show Gist options
  • Save xtrasmal/f9506fb77fb169075e539e0e4f97a160 to your computer and use it in GitHub Desktop.
Save xtrasmal/f9506fb77fb169075e539e0e4f97a160 to your computer and use it in GitHub Desktop.
AES encrypt mysql fields. Needs VARBINARY(112) columntypes
INSERT into encrypted_data (encrypted) VALUES (AES_ENCRYPT('let us hide this stuff', 'secretkey'));
SELECT AES_DECRYPT(encrypted, 'secretkey') from encrypted_data WHERE AES_DECRYPT(encrypted, 'secretkey') LIKE '%hide%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment