Libro de Visitas Gratis
Inicio | Directorio de Páginas | Diseño Gráfico | Gadgets | Posicionamiento | Webmasters| Buscador de Artículos | Glosarios

Script para encriptar y desencriptar a partir de una llave

Añade Tu Web Al Directorio de NocionDigital.com
<?
/* -----------------------------------------------
@Author: Developped by Chr1s@EZScripts.net
@Site: http://www.EZScripts.net/
-----------------------------------------------

How`s the my encryption algorithm work:

First it will generate an encryption key with the string you supply:

   Key 1 will be equal to the numerical value
   of each character in your crypt key.

   Key 2 will be equal to the length of your
   crypt key.

For each character in the string you wish to encrypt, it will do
the following mathematical calculations, where V is the final value
of the encoded character and C is the value of the character currently
encrypting:

   V = C * Key1
   V = V + Key2

It will then separate each character in the original string with
a character between 65 and 90 (cap. letters).

To decrypt the string, it will do the opposite calculations, where
V is the final value of the decrypted character and C is the value
of the encrypted character:

   V = V / Key1
   V = C – Key2 */

/* -----------------------------------------------
@Name: Encrypt()
@Args: $txt-> String to encrypt.
@Args: $CRYPT_KEY -> String used to generate a encryption key.
@Returns: $estr -> Encrypted string.
----------------------------------------------- */

function encrypt($txt,$CRYPT_KEY){
   if (!$txt && $txt != "0"){
     return false;
     exit;
}

   if (!$CRYPT_KEY){
     return false;
     exit;
   }

   $kv = keyvalue($CRYPT_KEY);
   $estr = "";
   $enc = "";

   for ($i=0; $i<strlen($txt); $i++) {
     $e = ord(substr($txt, $i, 1));
     $e = $e + $kv[1];
     $e = $e * $kv[2];
     (double)microtime()*1000000;
     $rstr = chr(rand(65, 90));
     $estr .= "$rstr$e";
   }

   return $estr;
}

/* -----------------------------------------------
@Name: Decrypt()
@Args: $txt-> String to decrypt.
@Args: $CRYPT_KEY -> String used to encrypt the string.
@Returns: $estr -> Decrypted string.
----------------------------------------------- */

function decrypt($txt, $CRYPT_KEY){
   if (!$txt && $txt != "0"){
     return false;
     exit;
   }

   if (!$CRYPT_KEY){
     return false;
     exit;
   }

   $kv = keyvalue($CRYPT_KEY);
   $estr = "";
   $tmp = "";

   for ($i=0; $i<strlen($txt); $i++) {
     if ( ord(substr($txt, $i, 1)) > 64 && ord(substr($txt,
$i, 1)) < 91 ) {
       if ($tmp != "") {
         $tmp = $tmp / $kv[2];
         $tmp = $tmp - $kv[1];
         $estr .= chr($tmp);
         $tmp = "";
       }
     } else {
       $tmp .= substr($txt, $i, 1);
     }
     }

   $tmp = $tmp / $kv[2];
   $tmp = $tmp - $kv[1];
   $estr .= chr($tmp);

   return $estr;
}
/* -----------------------------------------------
@Name: keyvalue()
@Args: $CRYPT_KEY -> String used to generate a encryption key.
@Returns: $keyvalue -> Array containing 2 encryption keys.
----------------------------------------------- */

function keyvalue($CRYPT_KEY){
   $keyvalue = "";
   $keyvalue[1] = "0";
   $keyvalue[2] = "0";
   for ($i=1; $i<strlen($CRYPT_KEY); $i++) {
     $curchr = ord(substr($CRYPT_KEY, $i, 1));
     $keyvalue[1] = $keyvalue[1] + $curchr;
     $keyvalue[2] = strlen($CRYPT_KEY);
   }
     return $keyvalue;
   }
?>
 
Hits
DOCUMENTOS RELACIONDOS
1972
Generador de imágenes en miniatura.
2952
Contraseñas de un solo uso.
2542
Qué son los frames.
4751
Como ocultar tus descargas.
2962
Cargar archivos Flash aleatoriamente.
2372
Menú que aparece y desaparece al pulsar encima de el.
2114
Cambiar un Enter por un BR (nl2br).
6880
Scroll para presentación de una página web.
7618
Todo sobre imágenes con JavaScript (rev.1).
7187
Códigos hexadecimales de color.
6658
Algoritmo recursivo para un arbol.
1610
Imprimir desde la página.
6708
Focus OnLoad.
10728
Saber el tamaño de una Base de Datos MySQL.
1579
Visitantes activos.
2093
Función para crear archivos.
1358
Redirección del Error de servidor 301 mediante ASP.
4325
Usuarios on-line, log de accesos y contador.
3139
Convertir Enteros a Binarios.
2727
Spotlight - efecto de luces (rev.1).


www.nociondigital.com - Todo para un mundo digital. Páginas Webs, Buscadores y Webmasters....