zoukankan      html  css  js  c++  java
  • PHP 双密码本

    <?php
    
    /**
     * @Description 加密
     * @param $str
     * @return array
     */
    function transform(string $str) : array
    {
        $booksecret = '+-. _@0123456789:qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ';
        $bookshuffle = str_shuffle($booksecret);
        $res = null;
        $strM = strlen($str);
    
        for($i = 0; $i < $strM; $i++){
            $postion = strpos($booksecret,$str[$i]);
            $res .= $bookshuffle[$postion];
        }
        $result['shuff'] = $bookshuffle;
        $result['req']   = $res;
        return $result;
    }
    $res = transform('Modified by: I will never know what the next difficulty is');
    
    /**
     * @Description 解密
     * @param $content
     * @return string
     */
    function gettrans(array $content) : string
    {
        $booksecret = '+-. _@0123456789:qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ';
        $shuff = $content['shuff'];
        $res = $content['req'];
        $strM = strlen($res);
    
        $con = null;
        for($i = 0; $i < $strM; $i++)
        {
            $con .= $booksecret[strpos($shuff,$res[$i])];
        }
        return $con;
    }
    echo gettrans($res);
  • 相关阅读:
    Promise
    ajax基础
    flex布局的盒子模型
    css3核心模块
    响应式开发
    HTML5标签及表单
    JS面向对象编程
    JS面向对象的编程
    ES5构造函数与ES6类
    类欧几里得算法
  • 原文地址:https://www.cnblogs.com/LF-place/p/14626939.html
Copyright © 2011-2022 走看看