npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aes-cross

v1.1.2

Published

A cross platform AES encryption-decryption with pkcs5Padding. support Java,javascript,typescript,C,Android,IOS...

Downloads

2,094

Readme

A real cross platforms AES encryption-decryption solution. Support Java,javascript,typescript,C,nodeJs,Android,IOS...

Build Status

中文说明

How to use AES cross platforms

Make these paras to be same in all platforms.

  • cipher mode: ECB,CBC,CFB,OFB,CTR,XTS...
  • key size: 128, 256
  • iv: init vector
  • padding: NoPadding,ZeroPadding,PKCS5Padding,PKCS7Padding,ISO10126Padding,ANSI X.923...
  • key: the key for encription and decryption

more information

nodejs api

const aes = require('aes-cross');
/**
 * AES encription
 * @param  {string/bytes} [target]
 * @param  {string/bytes} [key]         the length must be 16 or 32
 * @param  {string/bytes} [iv]       default is zero16IV
 * @param  {string} [inputEncoding]  ["utf8" -default,"ascii","base64","binary"...](https://nodejs.org/api/buffer.html#buffer_buffer)
 * @param  {string} [outputEncoding] ["base64" -default,"hex"...]
 * @param  {string} [algorithm] ["aes-128-cbc" -default]
 * @return {string}                 encription result
 */
 aes.enc(target, key, iv = zero16IV, inputEncoding = 'utf-8', outputEncoding = 'base64', algorithm = 'aes-128-cbc', autoPadding = true);

 /**
  * AES decription
  * @param  {string/bytes} [target]
  * @param  {string/bytes} [key]         the length must be 16 or 32
  * @param  {string/bytes} [iv]       default is zero16IV
  * @param  {string} [input_encoding]  ["utf8" - default,"ascii","base64","binary"...](https://nodejs.org/api/buffer.html#buffer_buffer)
  * @param  {string} [output_encoding] ["base64"- default ,"hex"...]
  * @param  {string} [algorithm] ["aes-128-cbc" -default]
  * @return {string}                 decription result
  */
  aes.dec(target, key, iv = zero16IV, inputEncoding = 'base64', outputEncoding = 'utf-8', algorithm = 'aes-128-cbc', autoPadding = true);

nodejs USEAGE

const aes = require('aes-cross');

const key = 'b9da49a54f15324d';
const src = 'abcde';

const key128iv = Buffer.from([12, 13, 12, 33, 33, 44, 3, 34, 44, 44, 9, 45, 28, 44, 22, 2]);
const key256iv = Buffer.concat([key128iv, key128iv]);


// aes-128-cbc
let enced = aes.enc(src, key, key128iv);
console.log('enced:', enced);
let deced = aes.dec(enced, key, key128iv);
console.log('deced:', deced);


// aes-128-ecb, ECB must use emptyIV
let algorithm = 'aes-128-ecb';

enced = aes.enc(src, key, aes.emptyIV, 'utf-8', 'base64', algorithm);
console.log('enced:', enced);
deced = aes.dec(enced, key, aes.emptyIV, 'base64', 'utf-8', algorithm);
console.log('deced:', deced);


// aes-256-cbc
algorithm = 'aes-256-cbc';
const orgText = 'asdfW  #)(ssff234';

enced = aes.enc(orgText, key256iv, aes.zero16IV, 'utf-8', 'base64', algorithm);
console.log('enced:', enced);
deced = aes.dec(enced, key256iv, aes.zero16IV, 'base64', 'utf-8', algorithm);
console.log('deced:', deced);

typescript

A pure AES in typescript, zero dependencies, can be used anywhere.

file: typescript/AES.ts

Read more