<?php
    class SGT_KEY {
        function bloq($word){
           $word .= $this->add_text;
           $s = strlen($word)+1;
           $nw = "";
           $n = $this->chave;
           for ($x = 1; $x < $s; $x++){
               $m = $x*$n;
               if ($m > $s){
                   $nindex = $m % $s;
               }
               else if ($m < $s){
                   $nindex = $m;
               }
               if ($m % $s == 0){
                   $nindex = $x;
               }
               $nw = $nw.$word[$nindex-1];
           }
           return $nw;
        }
        function ver($word){
           $s = strlen($word)+1;
           $nw = "";
           $n = $this->chave;
           for ($y = 1; $y < $s; $y++){
               $m = $y*$n;
               if ($m % $s == 1){
                   $n = $y;
                   break;
               }
           }
           for ($x = 1; $x < $s; $x++){
               $m = $x*$n;
               if ($m > $s){
                   $nindex = $m % $s;
               }
               else if ($m < $s){
                   $nindex = $m;
               }
               if ($m % $s == 0){
                   $nindex = $x;
               }
               $nw = $nw.$word[$nindex-1];
           }
           $t = strlen($nw) - strlen($this->add_text);
           return substr($nw, 0, $t);
        }
    }
# Criptografia
#$sgt_cript = new SGT_KEY();
#$sgt_cript -> chave = $chave_num;
#$sgt_cript -> add_text = md5(sha1($chave_txt));
#$key_crip = $sgt_cript -> bloq("Texto a ser criptografado");
# Descriptografar
#$sgt_cript = new SGT_KEY();
#$sgt_cript -> chave = $chave_num;
#$sgt_cript -> add_text = md5(sha1($chave_txt));
#$key_desc = $sgt_cript -> ver("Texto a ser descriptografado.");
?>