You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been running into some trouble that after enter the correct password developerPassword42069, the plaintext of the code is simple shown rather than the result of the execution of the code.
This is my code to encrypt files:
---layout: post---<imgsrc="{{ site.url }}{{ site.baseurl }}/assets/images/maps 1 cropped.png"alt="logo"class="align-center"style="margin-bottom: 10px;"><style>
/* Define CSS rules for the outer container */
#content_container {background-color: #283741;/* Set the background color */border-radius: 10px;/* Add rounded corners to the container */padding: 20px;/* Add padding to the container */}
/* Style for the input box */
#encrypt_password {width: 70%;/* Set the width to 70% of the container */padding: 10px;/* Add padding for spacing */border-radius: 5px;/* Add rounded corners to the input box */margin-bottom: 10px;/* Add space below the input */float: left;/* Float the input box to the left */border: none;/* Remove any border */outline: none;/* Remove the default outline */transition: background-color0.5sease,opacity0.5sease;/* Add transitions for smooth changes */}
/* Style for the unlock button */
#unlock_button {width: 28%;/* Set the width to 28% of the container */padding: 10px;/* Add padding for spacing */border-radius: 5px;/* Add rounded corners to the button */float: left;/* Float the button to the left */margin-left: 2%;/* Add a little space between the input and the button */border: none;/* Remove any border */outline: none;/* Remove the default outline */transition: opacity0.5sease;/* Add a transition for smooth fade-in/out */}
/* Clear the float to prevent layout issues */
.clearfix::after {content: ""; clear: both; display: table; } .content-container { border-radius: 10px; /* Add rounded corners to the container */ padding: 20px; /* Add padding to the container */ margin-bottom: 20px; /* Add bottom margin to create space between container and text below */ animation: breathing 2s infinite; /* Apply the breathing animation */ } @keyframes breathing { 0% { background-color: #5D676E; /* Start with red */ } 50% { background-color: #51454C; /* Transition to yellow at 50% */ } 100% { background-color: #5D676E; /* Return to red at 100% */ } }</style><div id="content_container"><divclass="content-container">
Password is the bold section of Common App Additional Information Section.
</div><formid="encrypt_form"action="#"method="post"class="clearfix"style="margin-top: 20px;"><!--Addmargin-topforspacing--><inputid="encrypt_password"type="password"name="password"placeholder="Enter password"autofocus/><inputid="unlock_button"type="submit"value="Unlock"/><!--Movethebuttontotheright--></form></div><scripttype="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script><script>
document.getElementById('encrypt_form').addEventListener('submit', function(e) {e.preventDefault();varpassphrase=document.getElementById('encrypt_password').value,encryptedMsgs=['{{ page.encrypted1 }}','{{ page.encrypted2 }}','{{ page.encrypted3 }}','{{ page.encrypted4 }}','{{ page.encrypted5 }}','{{ page.encrypted6 }}','{{ page.encrypted7 }}','{{ page.encrypted8 }}','{{ page.encrypted9 }}','{{ page.encrypted10 }}','{{ page.encrypted11 }}','{{ page.encrypted12 }}','{{ page.encrypted13 }}','{{ page.encrypted14 }}','{{ page.encrypted15 }}','{{ page.encrypted16 }}','{{ page.encrypted17 }}','{{ page.encrypted18 }}','{{ page.encrypted19 }}','{{ page.encrypted20 }}',];vardecryptedHTML=null;for(vari=0;i<encryptedMsgs.length;i++){varencryptedMsg=encryptedMsgs[i];varencryptedHMAC=encryptedMsg.substring(0,64);varencryptedHTML=encryptedMsg.substring(64);vardecryptedHMAC=CryptoJS.HmacSHA256(encryptedHTML,CryptoJS.SHA256(passphrase).toString()).toString();if(decryptedHMAC===encryptedHMAC){// Password matched, decrypt and display the content
decryptedHTML =CryptoJS.AES.decrypt(encryptedHTML,passphrase).toString(CryptoJS.enc.Utf8);break;}}
if (decryptedHTML) {// Change the background color of the input box to green to indicate a correct password immediatelydocument.getElementById('encrypt_password').style.backgroundColor='#82FF82';// Hide the input box and unlock button with a fade-out effectdocument.getElementById('encrypt_password').style.opacity=0;document.getElementById('unlock_button').style.opacity=0;// Use setTimeout to display the decrypted content after a delaysetTimeout(function(){// Display the decrypted contentdocument.getElementById('content_container').innerHTML=decryptedHTML;// Add a fade-in effect to the decrypted contentdocument.getElementById('content_container').style.opacity=1;},500);// Delay before displaying the content (adjust as needed)} else {// Change the background color of the input box to indicate an incorrect passworddocument.getElementById('encrypt_password').style.backgroundColor='#FF8282';// Set a timer to revert the background color back to its original state after 1 secondsetTimeout(function(){document.getElementById('encrypt_password').style.backgroundColor='';},1000);}});</script>
and this is to decrypt it using a the following Jekyll Themes Layout:
---
layout: post
---
<imgsrc="{{ site.url }}{{ site.baseurl }}/assets/images/maps 1 cropped.png" alt="logo" class="align-center" style="margin-bottom: 10px;"><style>
/* Define CSS rules for the outer container */
#content_container {
background-color: #283741; /* Set the background color */
border-radius: 10px; /* Add rounded corners to the container */
padding: 20px; /* Add padding to the container */
}
/* Style for the input box */
#encrypt_password {
width: 70%; /* Set the width to 70% of the container */
padding: 10px; /* Add padding for spacing */
border-radius: 5px; /* Add rounded corners to the input box */
margin-bottom: 10px; /* Add space below the input */
float: left; /* Float the input box to the left */
border: none; /* Remove any border */
outline: none; /* Remove the default outline */
transition: background-color 0.5s ease, opacity 0.5s ease; /* Add transitions for smooth changes */
}
/* Style for the unlock button */
#unlock_button {
width: 28%; /* Set the width to 28% of the container */
padding: 10px; /* Add padding for spacing */
border-radius: 5px; /* Add rounded corners to the button */
float: left; /* Float the button to the left */
margin-left: 2%; /* Add a little space between the input and the button */
border: none; /* Remove any border */
outline: none; /* Remove the default outline */
transition: opacity 0.5s ease; /* Add a transition for smooth fade-in/out */
}
/* Clear the float to prevent layout issues */
.clearfix::after {
content: "";
clear: both;
display: table;
}
.content-container {
border-radius: 10px; /* Add rounded corners to the container */
padding: 20px; /* Add padding to the container */
margin-bottom: 20px; /* Add bottom margin to create space between container and text below */
animation: breathing 2s infinite; /* Apply the breathing animation */
}
@keyframes breathing {
0% {
background-color: #5D676E; /* Start with red */
}
50% {
background-color: #51454C; /* Transition to yellow at 50% */
}
100% {
background-color: #5D676E; /* Return to red at 100% */
}
}
</style><divid="content_container"><divclass="content-container">
Password is the bold section of Common App Additional Information Section.
</div><formid="encrypt_form" action="#" method="post" class="clearfix" style="margin-top: 20px;"><!-- Add margin-top for spacing --><inputid="encrypt_password"
type="password"
name="password"
placeholder="Enter password"
autofocus />
<inputid="unlock_button" type="submit" value="Unlock"/> <!-- Move the button to the right --></form></div><scripttype="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script><script>document.getElementById('encrypt_form').addEventListener('submit',function(e){e.preventDefault();varpassphrase=document.getElementById('encrypt_password').value,encryptedMsgs=['{{ page.encrypted1 }}','{{ page.encrypted2 }}','{{ page.encrypted3 }}','{{ page.encrypted4 }}','{{ page.encrypted5 }}','{{ page.encrypted6 }}','{{ page.encrypted7 }}','{{ page.encrypted8 }}','{{ page.encrypted9 }}','{{ page.encrypted10 }}','{{ page.encrypted11 }}','{{ page.encrypted12 }}','{{ page.encrypted13 }}','{{ page.encrypted14 }}','{{ page.encrypted15 }}','{{ page.encrypted16 }}','{{ page.encrypted17 }}','{{ page.encrypted18 }}','{{ page.encrypted19 }}','{{ page.encrypted20 }}',];vardecryptedHTML=null;for(vari=0;i<encryptedMsgs.length;i++){varencryptedMsg=encryptedMsgs[i];varencryptedHMAC=encryptedMsg.substring(0,64);varencryptedHTML=encryptedMsg.substring(64);vardecryptedHMAC=CryptoJS.HmacSHA256(encryptedHTML,CryptoJS.SHA256(passphrase).toString()).toString();if(decryptedHMAC===encryptedHMAC){// Password matched, decrypt and display the contentdecryptedHTML=CryptoJS.AES.decrypt(encryptedHTML,passphrase).toString(CryptoJS.enc.Utf8);break;}}if(decryptedHTML){// Change the background color of the input box to green to indicate a correct password immediatelydocument.getElementById('encrypt_password').style.backgroundColor='#82FF82';// Hide the input box and unlock button with a fade-out effectdocument.getElementById('encrypt_password').style.opacity=0;document.getElementById('unlock_button').style.opacity=0;// Use setTimeout to display the decrypted content after a delaysetTimeout(function(){// Display the decrypted contentdocument.getElementById('content_container').innerHTML=decryptedHTML;// Add a fade-in effect to the decrypted contentdocument.getElementById('content_container').style.opacity=1;},500);// Delay before displaying the content (adjust as needed)}else{// Change the background color of the input box to indicate an incorrect passworddocument.getElementById('encrypt_password').style.backgroundColor='#FF8282';// Set a timer to revert the background color back to its original state after 1 secondsetTimeout(function(){document.getElementById('encrypt_password').style.backgroundColor='';},1000);}});</script>
Hello!
I have been using crypto.js to password protect some aspects of my website at www.ayanali.net/admissions/
I have been running into some trouble that after enter the correct password developerPassword42069, the plaintext of the code is simple shown rather than the result of the execution of the code.
This is my code to encrypt files:
and this is to decrypt it using a the following Jekyll Themes Layout:
and this is the page that uses this layout:
Thank you for the time taken to read this :)
The text was updated successfully, but these errors were encountered: