本文整理汇总了PHP中str_rot13函数的典型用法代码示例。如果您正苦于以下问题:PHP str_rot13函数的具体用法?PHP str_rot13怎么用?PHP str_rot13使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_rot13函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(array $inputs)
{
/** @var SecretMessage $message */
$message = $inputs[0];
$this->decoded = str_rot13($message->message);
return $this->decoded;
}
示例2: hash
/**
* Generate the message digest for the given message.
*
* An example usage is:
*
* <code>
* $message = "this is the message to be hashed";
*
* $test_gishiki_md5 = Algorithms::hash($message, Algorithms::MD5);
* $test_php_md5 = md5($message);
*
* if ($test_gishiki_md5 == $test_php_md5) {
* echo "Gishiki's MD5 produces the same exact hash of the PHP's MD5";
* }
* </code>
*
* @param string $message the string to be hashed
* @param string $algorithm the name of the hashing algorithm
* @param bool $binaryUnsafe if false the result is binhex
*
* @return string the result of the hash algorithm
*
* @throws \InvalidArgumentException the message or the algorithm is given as a non-string or an empty string
* @throws HashingException the error occurred while generating the hash for the given message
*/
public static function hash($message, $algorithm = self::MD5, $binaryUnsafe = false)
{
//check for the parameter
if (!is_bool($binaryUnsafe)) {
throw new \InvalidArgumentException('The binary safeness must be given as a boolean value');
}
//check for the message
if (!is_string($message) || strlen($message) <= 0) {
throw new \InvalidArgumentException('The message to be hashed must be given as a valid non-empty string');
}
//check for the algorithm name
if (!is_string($algorithm) || strlen($algorithm) <= 0) {
throw new \InvalidArgumentException('The name of the hashing algorithm must be given as a valid non-empty string');
}
if ($algorithm == self::ROT13) {
return str_rot13($message);
}
//check if the hashing algorithm is supported
if (!in_array($algorithm, openssl_get_md_methods()) && !in_array($algorithm, hash_algos())) {
throw new HashingException('An error occurred while generating the hash, because an unsupported hashing algorithm has been selected', 0);
}
//calculate the hash for the given message
$hash = in_array($algorithm, openssl_get_md_methods()) ? openssl_digest($message, $algorithm, $binaryUnsafe) : hash($algorithm, $algorithm, $binaryUnsafe);
//check for errors
if ($hash === false) {
throw new HashingException('An unknown error occurred while generating the hash', 1);
}
//return the calculated message digest
return $hash;
}
示例3: mudaSenha
public function mudaSenha($novaSenha)
{
// lemos as credenciais do banco de dados
$dados = file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/../config.json");
$dados = json_decode($dados, true);
foreach ($dados as $chave => $valor) {
$dados[$chave] = str_rot13($valor);
}
$host = $dados["host"];
$usuario = $dados["nome_usuario"];
$senhaBD = $dados["senha"];
// Cria conexão com o banco
$conexao = null;
try {
$conexao = new PDO("mysql:host={$host};dbname=homeopatias;charset=utf8", $usuario, $senhaBD);
} catch (PDOException $e) {
echo $e->getMessage();
}
$comando = "UPDATE Usuario SET senha = :senha WHERE id = :id";
$query = $conexao->prepare($comando);
// Fazemos o hash da senha usando a biblioteca phppass
$hasher = new PasswordHash(8, false);
$hashSenha = $hasher->HashPassword($novaSenha);
$query->bindParam(":senha", $hashSenha, PDO::PARAM_STR);
$query->bindParam(":id", $this->id, PDO::PARAM_INT);
$sucesso = $query->execute();
// Encerramos a conexão com o BD
$conexao = null;
return $sucesso;
}
示例4: user
public function user()
{
$db =& DB::connect('mysql://em:islam,nan,jaya@219.83.123.212/em');
if (PEAR::isError($db)) {
die($db->getDebugInfo());
}
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$res = $db->query('SELECT id, name, joint, level, pwd, clear_pwd, last FROM user LEFT JOIN user_pwd ON id=user_id WHERE id!="admin" ORDER BY id');
if (PEAR::isError($res)) {
die($res->getDebugInfo());
}
while ($row = $res->fetchRow()) {
$row['id'] = trim($row['id']);
if (!$row['id'] || preg_match('/[^0-9a-zA-Z-_@.]/', $row['id'])) {
echo "<p>Exclude '{$row['id']}'</p>";
continue;
}
$res2 = self::$dbh->query('INSERT INTO user (uid, name, mail, level, since) VALUES (?, ?, ?, ?, ?)', array($row['id'], $row['name'], $row['mail'], $row['level'], $row['joint']));
if (PEAR::isError($res2)) {
printf('%s<br/>', $res2->getDebugInfo());
}
$user_id = self::$dbh->getOne('SELECT id FROM user WHERE uid=?', array($row['id']));
$res3 = self::$dbh->query('INSERT INTO user_pwd (user_id, pwd, clear) VALUES (?, ?, ?)', array($user_id, $row['pwd'], str_rot13($row['clear_pwd'])));
if (PEAR::isError($res3)) {
printf('%s<br/>', $res3->getDebugInfo());
}
++$count;
}
printf("<p>{$count} Processed</p>");
}
示例5: filter
public function filter($in, $out, &$consumed, $closing) : int
{
while ($bucket = stream_bucket_make_writeable($in)) {
stream_bucket_append($out, stream_bucket_new($this->stream, str_rot13($bucket->data)));
}
return \PSFS_PASS_ON;
}
示例6: obfuscate
/**
* テンプレート関数
*/
function obfuscate($address)
{
$address = str_replace('@', '*', $address);
$address = str_replace('.', ':', $address);
$address = str_rot13($address);
return $address;
}
示例7: execute
function execute($par)
{
global $wgRequest, $wgEmailImage;
$size = 4;
$text = $wgRequest->getText('img');
/* decode this rubbish */
$text = rawurldecode($text);
$text = str_rot13($text);
$text = base64_decode($text);
$text = str_replace($wgEmailImage['ugly'], "", $text);
$fontwidth = imagefontwidth($size);
$fontheight = imagefontheight($size);
$width = strlen($text) * $fontwidth + 4;
$height = $fontheight + 2;
$im = @imagecreatetruecolor($width, $height) or exit;
$trans = imagecolorallocate($im, 0, 0, 0);
/* must be black! */
$color = imagecolorallocate($im, 1, 1, 1);
/* nearly black ;) */
imagecolortransparent($im, $trans);
/* seems to work only with black! */
imagestring($im, $size, 2, 0, $text, $color);
//header ("Content-Type: image/png"); imagepng($im); => IE is just so bad!
header("Content-Type: image/gif");
imagegif($im);
exit;
}
示例8: createFromDatabase
public function createFromDatabase()
{
require "config.php";
if (!isset($svnserve_user_file)) {
return;
}
$filename = $svnserve_user_file;
$accessfile = "## This SVNServe user file generated by SVNManager\n[users]\n";
$accessfile .= "\n";
$userresults = $this->database->Execute("SELECT * FROM users ORDER BY name");
while (!$userresults->EOF) {
$id = $userresults->fields['id'];
$password = $this->database->Execute("SELECT * FROM svnserve_pwd WHERE ownerid=" . makeSqlString($id));
if ($password->RecordCount() > 0) {
$accessfile .= $userresults->fields['name'] . " = " . str_rot13($password->fields['password']) . "\n";
}
$userresults->MoveNext();
}
$userresults->Close();
if (!($handle = fopen($filename, 'w'))) {
echo "Cannot open file ({$filename})";
exit;
}
if (fwrite($handle, $accessfile) === FALSE) {
echo "Cannot write to file ({$filename})";
exit;
}
fclose($handle);
}
示例9: it_encrypts_and_decrypts_cookies
/**
* @test
*/
public function it_encrypts_and_decrypts_cookies()
{
// Simulate a request coming in with several cookies.
$request = (new FigCookieTestingRequest())->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world');
// "Before" Middleware Example
//
// Get our token from an encrypted cookie value, "decrypt" it, and replace the cookie on the request.
// From here on out, any part of the system that gets our token will be able to see the contents
// in plaintext.
$request = FigRequestCookies::modify($request, 'sessionToken', function (Cookie $cookie) {
return $cookie->withValue(str_rot13($cookie->getValue()));
});
// Even though the sessionToken initially comes in "encrypted", at this point (and any point in
// the future) the sessionToken cookie will be available in plaintext.
$this->assertEquals('theme=light; sessionToken=ENCRYPTED; hello=world', $request->getHeaderLine(Cookies::COOKIE_HEADER));
// Simulate a response going out.
$response = new FigCookieTestingResponse();
// Various parts of the system will add set cookies to the response. In this case, we are
// going to show that the rest of the system interacts with the session token using
// plaintext.
$response = $response->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('theme', 'light'))->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('sessionToken', 'ENCRYPTED'))->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('hello', 'world'));
// "After" Middleware Example
//
// Get our token from an unencrypted set cookie value, "encrypt" it, and replace the cook on the response.
// From here on out, any part of the system that gets our token will only be able to see the encrypted
// value.
$response = FigResponseCookies::modify($response, 'sessionToken', function (SetCookie $setCookie) {
return $setCookie->withValue(str_rot13($setCookie->getValue()));
});
// Even though the sessionToken intiially went out "decrypted", at this point (and at any point
// in the future) the sessionToken cookie will remain "encrypted."
$this->assertEquals(['theme=light', 'sessionToken=RAPELCGRQ', 'hello=world'], $response->getHeader(SetCookies::SET_COOKIE_HEADER));
}
示例10: testFilterShouldPassReturnValueOfEachSubscriberToNextSubscriber
public function testFilterShouldPassReturnValueOfEachSubscriberToNextSubscriber()
{
$this->filterchain->connect('trim');
$this->filterchain->connect('str_rot13');
$value = $this->filterchain->filter(' foo ');
$this->assertEquals(\str_rot13('foo'), $value);
}
示例11: request
public function request()
{
if (!$this->session->exists()) {
$this->redirectNoSession();
return false;
}
if ($this->getRequestVar('save')) {
$filePath = base64_decode(str_rot13($this->getRequestVar('save')));
$file = new \fpcm\model\files\dbbackup(basename($filePath));
if (!$file->exists()) {
$this->view = new \fpcm\model\view\error();
$this->view->setMessage($this->lang->translate('GLOBAL_NOTFOUND_FILE'));
$this->view->render();
die;
}
header('Content-Description: File Transfer');
header('Content-Type: ' . $file->getMimetype());
header('Content-Disposition: attachment; filename="' . $file->getFilename() . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $file->getFilesize());
readfile($file->getFullpath());
exit;
}
return true;
}
示例12: checa_situacao_pagamentos_por_id
function checa_situacao_pagamentos_por_id($idAssociado)
{
// lemos as credenciais do banco de dados
$dados = file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/../config.json");
$dados = json_decode($dados, true);
foreach ($dados as $chave => $valor) {
$dados[$chave] = str_rot13($valor);
}
$host = $dados["host"];
$usuario = $dados["nome_usuario"];
$senhaBD = $dados["senha"];
// cria conexão com o banco
$conexao = null;
$db = "homeopatias";
try {
$conexao = new PDO("mysql:host={$host};dbname={$db};charset=utf8", $usuario, $senhaBD);
} catch (PDOException $e) {
echo $e->getMessage();
}
// selecionamos todos os pagamentos em aberto dos outros anos, e também selecionamos
// a inscrição desse ano caso ela esteja em aberto
$textoQuery = "SELECT NOT EXISTS\n (SELECT idPagAnuidade \n FROM PgtoAnuidade\n WHERE chaveAssoc = ? AND fechado = 0 AND (ano <> YEAR(CURDATE())\n OR inscricao = 1))\n AND EXISTS \n (SELECT idPagAnuidade FROM PgtoAnuidade WHERE ano = YEAR(CURDATE())\n AND chaveAssoc = ?) as emDia";
// se o associado estiver em dia com os pagamentos, essa query não deve retornar nada
$query = $conexao->prepare($textoQuery);
$query->bindParam(1, $idAssociado);
$query->bindParam(2, $idAssociado);
$query->setFetchMode(PDO::FETCH_ASSOC);
$query->execute();
$emDia = $query->fetch()['emDia'];
$conexao = null;
return $emDia;
}
示例13: cookie_encrypt
public function cookie_encrypt($username, $password, $rand)
{
$hold = hash('crc32b', str_rot13($password . $username . $rand));
$rand = hash('md5', 'old_skkooll');
$hold = hash('ripemd128', $hold . $rand);
return $hold;
}
示例14: fakeTranslation
function fakeTranslation($object)
{
// Find relational and meta fields we are not interested in writing right now.
$noninterestingFields = array('ID', 'Created', 'LastEdited', 'ClassName', 'RecordClassName', 'YMLTag', 'Version', 'URLSegment');
foreach (array_keys($object->has_one()) as $relation) {
array_push($noninterestingFields, $relation . 'ID');
}
// Write fields.
$modifications = 0;
foreach ($object->toMap() as $field => $value) {
if (in_array($field, $noninterestingFields)) {
continue;
}
// Skip non-textual fields
$dbObject = $object->dbObject($field);
if (!is_object($dbObject) || !$dbObject instanceof DBField) {
continue;
}
$class = get_class($dbObject);
if (!in_array($class, array('Varchar', 'HTMLText', 'Text'))) {
continue;
}
if ($class == 'HTMLText') {
$object->{$field} = "<p>" . nl2br(str_rot13(strip_tags($object->{$field}))) . "</p>";
} else {
$object->{$field} = str_rot13($object->{$field});
}
}
return $object;
}
示例15: convertToPHPValue
/**
* {@inheritdoc}
*
* @param string|null $value
* @param AbstractPlatform $platform
*
* @return string|null
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
return str_rot13($value);
}