gy-doc-code
[ class tree: gy-doc-code ] [ index: gy-doc-code ] [ all elements ]

Source for file Crypto.php

Documentation is available at Crypto.php

  1. <?php
  2.  
  3. namespace Gy\Core;
  4.  
  5. if (!defined("GY_CORE") && (GY_CORE !== true)) die( "gy: err include core" );
  6.  
  7. class Crypto
  8. {
  9.  
  10.     private $sole;
  11.  
  12.     /**
  13.      * setSole - установить соль (некая строка)
  14.      * @param string $sole 
  15.      * @return boolean true
  16.      */
  17.     public function setSole($sole)
  18.     {
  19.         $this->sole = $sole;
  20.         return true;
  21.     }
  22.  
  23.     /**
  24.      * getSole - получить значение соли
  25.      * @return string 
  26.      */
  27.     public function getSole()
  28.     {
  29.         return $this->sole;
  30.     }
  31.  
  32.     /**
  33.      * getRandString - даст произвольную строку
  34.      * @return string 
  35.      */
  36.     public function getRandString()
  37.     {
  38.         return md5(microtime().$this->sole);
  39.     }
  40.  
  41.     /**
  42.      * getStringForUserCookie - даст строку для пользовательской куки
  43.      *  (склеит соль имя id пользователя и сделает md5)
  44.      * @param string $login 
  45.      * @param string $name 
  46.      * @param int $id 
  47.      * @return string (md5)
  48.      */
  49.     public function getStringForUserCookie($login, $name, $id)
  50.     {
  51.         return md5(microtime().$login.$this->sole.$name.$id);
  52.     }
  53.  
  54. }

Documentation generated on Sat, 27 Apr 2024 11:17:29 +0300 by phpDocumentor 1.4.3