Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/09/2008, 10:41
Avatar de chitoso
chitoso
 
Fecha de Ingreso: mayo-2008
Ubicación: Montevideo, Uruguay
Mensajes: 205
Antigüedad: 16 años
Puntos: 5
Desacuerdo Respuesta: Problema de caracteres en cifrado/descifrado de datos

Lamentablemente no funcionó...

Copio todo el código y explico:

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Crypto Check</title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
    <body>
        <?php
            
require_once('classes/Security.php');
            
            if(isset(
$_POST['plaintext'])){
                
$text $_POST['plaintext'];
            }
            else{
                
$text '';
            }
            
            
// Cifrando //
            
if(isset($_POST['cifrar'])){
                
                
$output Security::Encrypt($text);
                
$output utf8_encode($output);
                
$b64 utf8_decode($output); //Para chequear si el base64decode coincide
            
}
            
            
// Descifrando //
            
if(isset($_POST['descifrar'])){
                
                
$b64 base64_decode($text);
                
$output Security::Decrypt($b64);
                
            }
            
        
?>
        <form action="index.php" method="post" charset="utf-8">
        <input type="text" name="plaintext" value="" maxlength="29" size="29"/>
        <input type="submit" name="cifrar" value="Cifrar" />
        <input type="submit" name = "descifrar" value="Descifrar" />
        </form>
        <br/>
        <?php echo "base64decode: <h2>" $b64"</h2>"?>
        <?php echo "Resultado: <h2>" $output"</h2>"?>
        
    </body>
</html>
Al cifrar:

Ingreso: 'nacho'
El resultado de codificar->encriptar es ‹äç®v˜-•Ñ¥EùA¡íV°IJº—Ú7Š4
No exactamente lo que me esperaba... Porque al copiar eso estoy en el mismo caso que antes, no descifra bien. Ni siquiera hace la codificación bien...

Alguna idea? Estoy haciendo algo mal?
__________________
Pasión por la Música