12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- declare(strict_types=1);
- namespace netico\Bones;
- /**
- * String obfuscation.
- *
- * ROT-13 + Zlib compression + base64 encoding.
- * See: https://stackoverflow.com/questions/2996049/how-to-compress-decompress-a-long-query-string-in-php.
- *
- * @package bones
- * @link https://git.lattuga.net/netico/code-library/src/master/Framework
- * @copyright Copyright (c) 2016, 2022 netico <netico@riseup.net>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License
- * @author netico <netico@riseup.net>
- *
- */
- class Obfuscation
- {
- /**
- * This is the method to obfuscate a string.
- *
- * @param string $str
- * @return string
- */
- public function obfuscate($str)
- {
- return rtrim(strtr(base64_encode(gzdeflate(str_rot13($str), 9)), '+/', '-_'), '=');
- }
- /**
- * This is the method to deobfuscate a string.
- *
- * @param string $str
- * @return string
- */
- public function deobfuscate($str)
- {
- return str_rot13(gzinflate(base64_decode(strtr($str, '-_', '+/'))));
- }
- }
|