proba1 avatar

Learn to Protect Yourself - Basic Offline Encryption Tool - Javascript Tutorial

proba1

Published: 09 Jul 2018 › Updated: 09 Jul 2018Learn to Protect Yourself - Basic Offline Encryption Tool - Javascript Tutorial

Learn to Protect Yourself - Basic Offline Encryption Tool - Javascript Tutorial

Repository

https://github.com/blws/text-encrypt

1gtlUpb.png

About text-encrypt



Offline minimal encryption tool and key generator.
Website: https://blws.github.io/text-encrypt

combination.gif

Technology Stack

Javascript, html, css

Roadmap

This is standalone offline text encryptor and key generator.
There is no roadmap, because it simply works.

New Features

1 - Basic Layout

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Crypt</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        * {margin: 0 auto;padding: 0;}
        .w1 {width: 100%;}
        .w2 {width: 50%;float: left;}
        .h1 {height: 300px;}
    </style>
</head>
<body>
    <input id="pass" placeholder="strong password" class="w2" type="text"></input>
    <label> Length: </label>
    <input id="limit" type="text" value="8" style="width:36px;"></input>
    <button onclick="generate()">Generate</button>
    <br>
    <textarea id="dtext" placeholder=" decrypted text" class="w1 h1"></textarea>
    <br>
    <button class="w2" onclick="enc()">encrypt</button>
    <button class="w2" onclick="dec()">decrypt</button>
    <br>
    <textarea id="etext" placeholder=" encrypted text" class="w1 h1"></textarea>
</body>
</html>

https://github.com/blws/text-encrypt/blob/master/index.html#L1
https://github.com/blws/text-encrypt/blob/master/index.html#L2408

2 - Generate Password or choose your own

//generate key / password
function generate() {
            var text = "";
            var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var limit = parseInt(document.getElementById("limit").value);
            for (var i = 0; i < limit; i++)
                text += possible.charAt(Math.floor(Math.random() * possible.length));
            document.getElementById("pass").value = text;
        }

https://github.com/blws/text-encrypt/blob/master/index.html#L2442

3 - Encrypt text

//encrypt text
//hashing password / key with SHA256
//encrypting - AES
function enc() {
    var pass = document.getElementById("pass").value;
    var passHash = CryptoJS.SHA256(pass).toString();
    var dtext = document.getElementById("dtext").value; //.replace(/(?:\r\n|\r|\n)/g, '');
    document.getElementById("etext").value =
        CryptoJS.AES.encrypt(dtext, passHash).toString();
}

https://github.com/blws/text-encrypt/blob/master/index.html#L2419
4 - Decrypt text

//decrypt text
//hashing password / key with SHA256
//decrypting - AES
function dec() {
    var pass = document.getElementById("pass").value;
    var passHash = CryptoJS.SHA256(pass).toString();
    var etext = document.getElementById("etext").value;
    document.getElementById("dtext").value =
        CryptoJS.AES.decrypt(etext, passHash)
        .toString(CryptoJS.enc.Utf8);
}

https://github.com/blws/text-encrypt/blob/master/index.html#L2430

GitHub Account

https://github.com/blws

Leave Learn to Protect Yourself - Basic Offline Encryption Tool - Javascript Tutorial to:

Written by

Freelancer | Programmer | Web Developer | Consultant | EOS Enthusiast

Read more #utopian-io posts


Best Posts From proba1

We have not curated any of proba1's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From proba1