Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

Creating Custom Encryption and Decryption Engine with JavaScript

Posted on September 7, 2017August 4, 2020 by Habibie

In this video tutorial I will show you how to create a simple Encryption and Decryption engine in JavaScript.

Watch this tutorial here:

Here is the source code. But, like I’ve told in this video, it’s not completed yet.

<!DOCTYPE html>
<html>
	<head>
		<title>zkTutorials</title>
	</head>
	<body>
		<input placeholder="Type something" id="myinput">
		<button onclick="encrypt()">Encrypt</button>
		<button onclick="decrypt()">Decrypt</button>
		<div id="result"></div>
		<script>
			function encrypt(){
				var rawtext = document.getElementById("myinput").value;
				var temptext = "";
				for(i = 0; i < rawtext.length; i++){
					temptext += enc(rawtext[i]);
				}
				document.getElementById("result").innerHTML = temptext;
			}
			function decrypt(){
				var rawtext = document.getElementById("myinput").value;
				var temptext = "";
				for(i = 0; i < rawtext.length; i++){
					temptext += dec(rawtext[i]);
				}
				document.getElementById("result").innerHTML = temptext;
			}
			function enc(x){
				switch(x){
					case "a" :
						return ".";
						break;
					case "b" :
						return "0";
						break;
					case "c" :
						return "_";
						break;
					case "d" :
						return "=";
						break;
				}
			}
			function dec(x){
				switch(x){
					case "." :
						return "a";
						break;
					case "0" :
						return "b";
						break;
					case  "_":
						return "c";
						break;
					case  "=":
						return "d";
						break;
				}
			}
		</script>
	</body>
</html>
Post Views: 435
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme