nggit/php-rot-encoding

dev-master 2019-01-15 01:10 UTC

This package is auto-updated.

Last update: 2024-09-15 14:01:59 UTC


README

PHP Rot Encoding

提示: 将此 md 文件重命名为 php 以在您的 Web 服务器上测试。

<?php

require 'src/Rot.php';

$str = "Have you not heard the stories? Captain Barbossa and his crew of miscreants sail from the dreaded
        Isla de Muerta. It's an island that cannot be found except by those who already know where it is.";

$rot = new Nggit\PHPRotEncoding\Rot($str);

使用密钥 2154 对字符串进行编码

$encoded = $rot->encode(2154);
// Or separate by commas:
// $encoded = $rot->encode(2, 1, 5, 4);
echo '<br />';

显示编码后的字符串

echo $encoded;
// Hsst hbboeeBp alxanI l. bi torsu.aiadrtftrotwoeu?c ina ata reoysh atkwancdost r� au i 'twie nsr t ah
//  m idrfyesi vo d sneetr etp ey aeeednas fht�I eeMachhdnaowls er n l s hs nctda�mea dnCihos�deraoo
echo '<br />';

解码编码后的字符串

echo $rot->decode();
// Have you not heard the stories? Captain Barbossa and his crew of miscreants sail from the dreaded
// Isla de Muerta. It's an island that cannot be found except by those who already know where it is.
echo '<br />';

使用另一个实例解码编码后的字符串

$rot1 = new Nggit\PHPRotEncoding\Rot($encoded);
echo $rot1->decode(2154);
// Have you not heard the stories? Captain Barbossa and his crew of miscreants sail from the dreaded
// Isla de Muerta. It's an island that cannot be found except by those who already know where it is.
echo '<br />';

如果密钥不匹配怎么办?

echo $rot1->decode(124);
// Hh ertoaen d uvaoyc mwscfrhi r eisoan eoittfsamlsr eh ed ae dr d lwha e rhoda keosyhaes repsttCi ?oBt
//  bndsaaao �arinsxu p fbcntteoyed tentd ah o bnatc rw.ihnie �teos wu l edI Ma �es ris.antts n 'al
exit;

?>

尽管如此,我并不保证这是安全的。请自行承担风险使用!