Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate CakePHP configuration value for security, Security.salt and Security.cipherSeed.
<?php
$salt = genrandom(40);
$seed = genrandom(29, "0123456789");
echo "\tConfigure::write('Security.salt', '$salt');\n";
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n";
function genrandom($len, $salt = null) {
if (empty($salt)) {
$salt = salt('a', 'z'). salt('A', 'Z'). salt('0', '9');
}
$str = "";
for ($i = 0; $i < $len; $i++) {
$index = rand(0, strlen($salt) - 1);
$str .= $salt[$index];
}
return $str;
}
function salt($from, $end) {
$salt = '';
for ($no = ord($from); $no <= ord($end); $no++) {
$salt .= chr($no);
}
return $salt;
}
@intuxicated

This comment has been minimized.

Copy link

intuxicated commented May 2, 2013

thanks :)

@zhmz1326

This comment has been minimized.

Copy link

zhmz1326 commented May 8, 2013

Thank u!

@toghou-j

This comment has been minimized.

Copy link

toghou-j commented May 14, 2013

awesome !!

@udev

This comment has been minimized.

Copy link

udev commented Jul 3, 2013

Thanks :D

@TeddyBear06

This comment has been minimized.

Copy link

TeddyBear06 commented Nov 4, 2013

Thanks :-)

@rgrigga

This comment has been minimized.

Copy link

rgrigga commented Jul 25, 2014

Thank you!

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