GithubHelp home page GithubHelp logo

shiddenme / god_crypto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from invisal/god_crypto

0.0 0.0 0.0 127 KB

Pure Javascript/Typescript Crypto Implementation for Deno. AES, RSA, HMAC, and TOTP

License: MIT License

TypeScript 100.00%

god_crypto's Introduction

God Crypto

test

A pure Javascript/Typescript cryptography implementation for Deno. We will try to use WebCrypto if available, then fallback to WebAssembly implementation if available, otherwise, we will use pure Javascript implementation.

NOTE: god_crypto is in very early stage of development. There will be a lot of change and it is not recommended for production.

References

Click here for complete document: Complete Documents

Modules

You can choose to include the whole god_crypto implementation or just include module that you need.

// Load everything
import { AES, RSA, TOTP, hmac, encode } from "https://deno.land/x/god_crypto/mod.ts";

// Load what you need
import { AES }  from "https://deno.land/x/god_crypto/aes.ts";
import { RSA }  from "https://deno.land/x/god_crypto/rsa.ts";
import { TOTP } from "https://deno.land/x/god_crypto/otp.ts";
import { hmac } from "https://deno.land/x/god_crypto/hmac.ts";

Support Algorithms

WebCrypto WebAssembly Javascript
AES
   AES-CBC ✔️ ✔️
   AES-CFB ✔️
   AES-ECB ✔️
RSA
   RSA-PKCS1 v1.5 ✔️
   RSA-OAEP ✔️ ✔️
HMAC ✔️
TOTP ✔️

More algorithm supports is one the way


Examples

import { AES } from "https://deno.land/x/god_crypto/aes.ts";

const aes = new AES("Hello World AES!", {
  mode: "cbc",
  iv: "random 16byte iv",
});
const cipher = await aes.encrypt("This is AES-128-CBC. It works.");
console.log(cipher.hex());
// 41393374609eaee39fbe57c96b43a9da0d547c290501be50f983ecaac6c5fd1c

const plain = await aes.decrypt(ciper);
console.log(plain.toString());
// This is AES-128-CBC. It works.
import { RSA } from "https://deno.land/x/god_crypto/rsa.ts";

// Parsing public/private key
const publicKey = RSA.parseKey(Deno.readTextFileSync("./public.pem"));
const privateKey = RSA.parseKey(Deno.readTextFileSync("./private.pem"));

const cipher = await new RSA(publicKey).encrypt("Hello World");
console.log(ciper.base64());

const plain = await new RSA(privateKey).decrypt(cipher);
console.log(plain.toString());

god_crypto's People

Contributors

invisal avatar larshp avatar wonism avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.