Skip to main content
Deno 2 is finally here 🎉️
Learn more

God Crypto

Forked from God Crypto.

I only want fix the typescript lint error which caused in https://deno.land/x/god_crypto@v1.4.10/src/aes/aes_wc.ts#L25.

error: TS2345 [ERROR]: Argument of type '"jwk"' is not assignable to parameter of type '"raw"'.
        "jwk",
        ~~~~~

It seems like that the lint rule changed when typescript version update.

I just changed it because I have to use it now. I will not maintenance code if the origin code fixed it.


test Quality Gate Status

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

References

Supported Algorithms

Applications

Ultities

Some useful ultities that you can use

Click here for complete document: Complete Documents

Modules

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

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

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

Examples

import { AES } from "https://deno.land/x/god_crypto_jw/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(cipher);
console.log(plain.toString());
// This is AES-128-CBC. It works.
import { RSA } from "https://deno.land/x/god_crypto_jw/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());