Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

dstettler/hat.sh

Repository files navigation

PLEASE READ THIS SECTION

This is a heavily modified version of hat.sh designed to make it integrate better with desktop environments. If you want to just use the webapp, please use the regular repository here, because this will likely not run the way you would like it to on your web browser.

I'll try to update this with any updates sh-dev puts out on the 1.5 branch, and intend to port v2 to Electron once it is officially out of beta.




hat.sh is a javascript app that provides secure file encryption using the AES-256-GCM algorithm from WebCryptoAPI provided by your browser. it was coded following the WebCrypto Documentations.

It's fast, secure and Serverless, the app never uploads the files to the server.

in a small amount of code the app can encrypt any type of files at any size within seconds.

To use the app all you have to do is Browse a file, Type a Decryption Key or Generate one through our secure key generator. and your encrypted file is ready to download.

Requirements

NodeJS and NPM

Browserify which lets you require('modules') in the browser by bundling up all of your dependencies.


Installation

Download or clone the repository

$ git clone https://github.com/deevonstutter/hat.sh.git hat.sh

go to the app directory

cd [app directory]

now run

npm run full-build

which will install all the node dependencies and build the Browserify bundle. At this point you can run the electron


NEW SCRIPTS

Though this is mostly for electron support, I do have some scripts that can be run from the root directory as well. Also please keep in mind these scripts were built for WINDOWS ONLY.


npm run build

This will run the Browserify build process and copy the resulting bundle.js to the Electron directory.


npm run full-build

This is really just for initializing your build environment.


npm run e-serve

This will run the Electron instance.


Browser Compatibility

We officially support the last two versions of every major browser. Specifically, we test on the following

  • Chrome on Windows, macOS, and Linux , IOS, Android
  • Firefox on Windows, macOS, and Linux
  • Safari on iOS and macOS
  • Edge on Windows
  • IE 11 on Windows

for more info see WebCryptoAPI home page enter image description here

Crypto Examples

AES-GCM - generateKey

  window.crypto.subtle.generateKey(
    {
      name: "AES-GCM",
      length: 256,
    },
    true,
    ["encrypt", "decrypt"]
  )
.then(function(key){
    console.log(key);
})
.catch(function(err){
    console.error(err);
});

AES-GCM - importKey

function importSecretKey(rawKey) {
    return window.crypto.subtle.importKey(
      "raw",
      rawKey,
      "AES-GCM",
      true,
      ["encrypt", "decrypt"]
    );
  }
.then(function(key){
    console.log(key);
})
.catch(function(err){
    console.error(err);
});

AES-GCM - exportKey

async function exportCryptoKey(key) {
    const exported = await window.crypto.subtle.exportKey(
      "raw",
      key
    )
.then(function(keydata){
    console.log(keydata);
})
.catch(function(err){
    console.error(err);
});

AES-GCM - encrypt

async function encryptMessage(key) {
    let encoded = getMessageEncoding();
    // The iv must never be reused with a given key.
    iv = window.crypto.getRandomValues(new Uint8Array(12));
    ciphertext = await window.crypto.subtle.encrypt(
            {
                name: "AES-GCM",
                iv: iv
            },
            key,
            encoded
        )
        .then(function (encrypted) {
            console.log(new Uint8Array(encrypted));
        })
        .catch(function (err) {
            console.error(err);
        });
}

AES-GCM - decrypt

async function decryptMessage(key) {
    let encoded = getMessageEncoding();
    let decrypted = await window.crypto.subtle.decrypt({
            name: "AES-GCM",
            iv: iv
        },
        key,
        ciphertext
       )
       .then(function (decrypted) {
            console.log(new Uint8Array(encrypted));
        })
        .catch(function (err) {
            console.error(err);
        });
}

Credits

zxcvbn.js for Smart Password Strength Estimation

bootstrap for the responsive css layout

font-awesome for the icons

License

Copyright (c) 2019 sh-dv

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published