aykxt / crypto Goto Github PK
View Code? Open in Web Editor NEW๐ Fastest crypto library for Deno written in pure Typescript. AES, Blowfish, CAST5, DES, 3DES, HMAC, HKDF, PBKDF2
Home Page: https://deno.land/x/crypto
License: MIT License
๐ Fastest crypto library for Deno written in pure Typescript. AES, Blowfish, CAST5, DES, 3DES, HMAC, HKDF, PBKDF2
Home Page: https://deno.land/x/crypto
License: MIT License
Hi there! First of all, love your lib. Just started getting into Deno myself and it's nice to see a good crypto library already exists. I'm working on porting another very large project to Deno, and it requires the AES-IGE block cipher. IGE isn't used much at all except by Telegram for their MTProto protocol, but it would be really helpful to me to have it available in your library.
My typescript AES result is different from golang language, typescript is client language, and golang is my server language.
Then I try some AES website like https://the-x.cn/en-US/cryptography/Aes.aspx, and I found golang AES result is same as the website AES result.
Here is my code.
const te = new TextEncoder();
const key = te.encode("1234567899999999");
const data = te.encode("1234");
const iv = new Uint8Array(16)
for (let i = 0; i < key.length; i++) {
iv[i] = key[i]
}
const cipher = new Cbc(Aes, key, iv, Padding.PKCS7);
const encrypted = cipher.encrypt(data);
const base64 = Base64.encode(encrypted)
The typescript AES result = CbV6UFL7HC7H1smYlwliVg==
The golang AES result = S7gxtGIbOdtmzhn4vAW13A==
The website AES result = S7gxtGIbOdtmzhn4vAW13A==
It's so strange and I am checking my code, does my code has any problem?
Hello, I just see this Deno module and I want to use it.
here is my code:
import { Aes } from 'https://deno.land/x/[email protected]/aes.ts';
import { Cbc, Padding } from 'https://deno.land/x/[email protected]/block-modes.ts';
export default function encrypt(encData: string, encKey: string) {
const te = new TextEncoder();
const key = te.encode(encKey);
const data = te.encode(encData);
const iv = new Uint8Array(16);
const cipher = new Cbc(Aes, key, iv, Padding.PKCS7);
return cipher.encrypt(data);
}
however, running
console.log(encrypt("ABC123456", "VeryStrongPassword"));
return this error
error: Uncaught Error: Invalid key size (must be either 16, 24 or 32 bytes)
throw new Error("Invalid key size (must be either 16, 24 or 32 bytes)");
How do I fix this? New to Deno.
Thank you (and sorry in case this is a foolish question).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.