html and js encryption

1

I want to know how to encrypt an html page, that when you look at the html code you will not see anything, and I will mimic it with your js.

Try to code the page, but if you saw the source code they opened the information

pal=prompt('Introduce la clave','') ;
    if(pal!="clave123"){

        location.reload();
    }
    
asked by Andrés Vélez 06.04.2018 в 01:24
source

1 answer

0

If you really want to encrypt the html you can use CryptoJS, once decrypted you see the code in the inspector, but if you do not know the key I guess it's worth it.

var secreto="U2FsdGVkX1+n17bqE1MxKKOH5cok3j64MQY0TTBGp5HXolT8IRdcW+QAGsFMLt/yrxN1DTuWzV2ihm3fzUy4JPahsNuymmtFmSJA+QgF6lTpyw7ouIZwVZMRSVvLOaTV";
$(function(){
  $("#dejameEntrar").on("click", function(){
    var pass = $("#clave").val();
    var desencryptado = CryptoJS.AES.decrypt(secreto, pass).toString(CryptoJS.enc.Utf8);
    $("#asgard").html(desencryptado);
  });
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>L'Encriptau</title>
</head>
<body>
  <div id="Heimdall">
    <input
      type="password"
      id="clave"
      name="clave"
      placeholder="Ingresa el Secret Key"
      value=""/>
    <button id="dejameEntrar">Enviar</button>
  </div>
  <div id="asgard">
  </div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script>
</html>

PS: the key is "My Super $ password" without quotes.

To encrypt here is a snippet

$(function(){
   $("#dameLaCrypto").on("click", function(){
    var elHtml = $("#elhtml").val();
    var laKey = $("#clave").val();
    var encrypteado = CryptoJS.AES.encrypt( elHtml, laKey).toString();
    $("#encrypteado").val(encrypteado);
    console.log(encrypteado, laKey);
  });    
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>L'Encriptadeur</title>
</head>
<body>
<textarea id="elhtml" placeholder="el HTML a encryptar" rows="5" cols="32"></textarea><br />
<input 
      type="password"
      id="clave"
      name="clave"
      placeholder="Ingresa el Secret Key"
      value=""/>
 <button id="dameLaCrypto">Enviar</button>
 <p>aqui debajo va la cadena encriptada</p>
 <textarea id="encrypteado" rows="5" cols="32"></textarea>
</body>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script>
</html>

In the example the CDN is used, but you can also import the library with npm or bower

link

    
answered by 11.06.2018 в 01:02