本文整理汇总了PHP中CASHSystem::getSystemSalt方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::getSystemSalt方法的具体用法?PHP CASHSystem::getSystemSalt怎么用?PHP CASHSystem::getSystemSalt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASHSystem
的用法示例。
在下文中一共展示了CASHSystem::getSystemSalt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateCode
protected function generateCode($all_chars, $code_break, $last_code = false)
{
$seed = CASHSystem::getSystemSalt();
$this->consistentShuffle($all_chars, $seed);
$this->consistentShuffle($code_break, $seed);
if (!$last_code) {
$last_code = '';
for ($i = 1; $i <= 10; $i++) {
$last_code .= $all_chars[rand(0, count($all_chars) - 1)];
}
}
$sequential = substr($last_code, 1, $code_break[0]) . substr($last_code, 0 - (7 - $code_break[0]));
$sequential = $this->iterateChars($sequential, $all_chars);
$new_code = $all_chars[rand(0, count($all_chars) - 1)] . substr($sequential, 0, $code_break[0]) . $all_chars[rand(0, count($all_chars) - 1)] . $all_chars[rand(0, count($all_chars) - 1)] . substr($sequential, 0 - (7 - $code_break[0]));
return $new_code;
}
示例2: simpleXOR
/**
* Super basic XOR encoding — used for encoding connection data
*
*/
public static function simpleXOR($input, $key = false)
{
if (!$key) {
$key = CASHSystem::getSystemSalt();
}
// append key on itself until it is longer than the input
while (strlen($key) < strlen($input)) {
$key .= $key;
}
// trim key to the length of the input
$key = substr($key, 0, strlen($input));
// Simple XOR'ing, each input byte with each key byte.
$result = '';
for ($i = 0; $i < strlen($input); $i++) {
$result .= $input[$i] ^ $key[$i];
}
return $result;
}