Ir para conteúdo
Fórum Script Brasil

Leandro Aparecido

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Leandro Aparecido

Leandro Aparecido's Achievements

0

Reputação

  1. Boa noite! Estou fazendo um sistema bem simples de criptografia, estou usando a função str_replace, porém o resultado é muito estranho não substitui corretamente, já tentei diversas alternativas mas sem sucesso, alguém poderia me dar uma dica, segue o código abaixo: <html> <head> <title>Sistema de Criptografar</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="estilo.css"> </head> <body> <center> <form action="" method="POST" > <h1>Sistema de Criptografia</h1><br/> <label>Digite a Chave: </label><br/> <input type="text" class='texto' name="chave" value="" /><br/><br/> <label>Digite o texto:</label><br/> <textarea name="texto" rows="0" cols="0"></textarea><br/><br/> <input type="submit" value="Criptografar" name="enviar" class="submit" /> <input type="submit" value="Descriptografar" name="enviar" class="submit" /> </form> </center> <?php if(isset($_POST["enviar"])){ $texto=$_POST['texto']; $chave=$_POST['chave']; $seg=123; $criptoalterar = array ("a","b","c","d","e","f","g","h","i","j","l","m","n","o","p","q","r","s","t","u","v","x","z"); $criptoalterado = array ("u","n","r","o","p","t","6","y","k","w","q","9","5","v","6","c","0","x","h","3","b","7","f"); if ($chave== "") { echo '<center class="format">Campo chave é obrigatório</center>'; exit(); } if ($chave!=$seg){ echo 'Chave Incorreta Verifique e tente novamente!'; exit(); } switch ($_POST['enviar']){ case 'Criptografar': $alterar = str_replace($criptoalterar, $criptoalterado, $texto); echo $alterar; break; case 'Descriptografar': $voltar = str_replace($criptoalterado, $criptoalterar, $texto); echo $voltar; break; default: } } ?> </body> </html>
×
×
  • Criar Novo...