Skip to content

Instantly share code, notes, and snippets.

@Darep
Created February 27, 2016 02:17
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 Darep/cb94500c8fbb70c4a226 to your computer and use it in GitHub Desktop.
Save Darep/cb94500c8fbb70c4a226 to your computer and use it in GitHub Desktop.
<?php
/**
* Encrypts a "secrets.json" file using mcrypt
*
* Usage: php secrets_encrypt.php > secrets.ejson
*/
require(dirname(__FILE__) . '/key.php');
function _secrets_encrypt($string) {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(SECRET_KEY), $string, MCRYPT_MODE_CBC, md5(md5(SECRET_KEY))));
}
$plain_json = file_get_contents(dirname(__FILE__) . '/secrets.json');
if ($plain_json !== FALSE) {
echo _secrets_encrypt($plain_json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment