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

Commit

Permalink
Use ES6 classes and change PhantomJS to Puppeteer in testing (#135)
Browse files Browse the repository at this point in the history
* Use ES6 classes and change PhantomJS to Puppeteer in testing

* Change to uglify-es.

* Remove IE10 support permanently, remove IE11 support temporarily (it will be added back with transpiling). Remove the really old Safari, Firefox, Chrome support.

* Remove NodeJS 6 support
  • Loading branch information
alippai authored Jan 2, 2018
1 parent 245a288 commit 59fa073
Show file tree
Hide file tree
Showing 27 changed files with 1,541 additions and 1,194 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- '6'
- '8'
- '9'
sudo: false
Expand Down
211 changes: 104 additions & 107 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,120 @@
// Grunt setup
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-rollup');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-rollup');
grunt.loadNpmTasks('grunt-shell');

// Finally, configure
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Finally, configure
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

rollup: {
options: {
format: 'umd',
sourceMap: true,
banner: "/*! asmCrypto<%= pkg.version && ' v'+pkg.version %>, (c) 2018 <%= pkg.author.name %>, opensource.org/licenses/<%= pkg.license %> */",
},
default: {
options: {
moduleName: 'asmCrypto',
},
files: {
'asmcrypto.js': './src/entry-default.js'
}
},
all: {
options: {
moduleName: 'asmCrypto',
},
files: {
'asmcrypto.all.js': './src/entry-export_all.js'
}
},
all_esm: {
options: {
format: 'es',
},
files: {
'asmcrypto.mjs': './src/entry-export_all.js'
}
},
test_AES_ASM: {
options: {
moduleName: 'AES_asm',
},
files: {
'test/aes.asm.js': './src/aes/aes.asm.js'
}
},
rollup: {
options: {
format: 'umd',
sourceMap: true,
banner: "/*! asmCrypto<%= pkg.version && ' v'+pkg.version %>, (c) 2018 asmCrypto.js, opensource.org/licenses/<%= pkg.license %> */",
},
default: {
options: {
moduleName: 'asmCrypto',
},

uglify: {
options: {
mangle: {},
compress: {},
sourceMap: true,
sourceMapIn: 'asmcrypto.js.map',
sourceMapIncludeSources: true,
screwIE8: true,
banner: "/*! asmCrypto<%= pkg.version && ' v'+pkg.version %>, (c) 2018 <%= pkg.author.name %>, opensource.org/licenses/<%= pkg.license %> */"
},
all: {
files: {
'asmcrypto.min.js': 'asmcrypto.js'
}
}
files: {
'asmcrypto.js': './src/entry-default.js',
},

jsdoc: {
all: {
src: ['src/**/*.js', 'README.md'],
options: {
destination: 'doc'
}
}
},
all: {
options: {
moduleName: 'asmCrypto',
},
files: {
'asmcrypto.all.js': './src/entry-export_all.js',
},
},
all_esm: {
options: {
format: 'es',
},
files: {
'asmcrypto.mjs': './src/entry-export_all.js',
},
},
test_AES_ASM: {
options: {
moduleName: 'AES_asm',
},
files: {
'test/aes.asm.js': './src/aes/aes.asm.js',
},
},
},

qunit: {
all: {
options: {
timeout: 120000,
urls: ['http://localhost:9999/index.html']
}
}
shell: {
test: {
command: '"./node_modules/.bin/qunit-puppeteer" http://localhost:9999/index.html'
}
},

uglify: {
options: {
mangle: {},
compress: {},
sourceMap: true,
sourceMapIn: 'asmcrypto.js.map',
sourceMapIncludeSources: true,
screwIE8: true,
banner: "/*! asmCrypto<%= pkg.version && ' v'+pkg.version %>, (c) 2018 asmCrypto.js, opensource.org/licenses/<%= pkg.license %> */",
},
all: {
files: {
'asmcrypto.min.js': 'asmcrypto.js',
},
},
},

connect: {
all: {
options: {
hostname: 'localhost',
port: 9999,
base: ['test', '.'],
directory: 'test'
}
}
jsdoc: {
all: {
src: ['src/**/*.js', 'README.md'],
options: {
destination: 'doc',
},
},
},

watch: {
all: {
files: 'src/**/*.js',
tasks: ['rollup:all', 'rollup:test_AES_ASM']
}
connect: {
all: {
options: {
hostname: 'localhost',
port: 9999,
base: ['test', '.'],
directory: 'test',
},
},
},

watch: {
all: {
files: 'src/**/*.js',
tasks: ['rollup:all', 'rollup:test_AES_ASM'],
},
},

clean: [
'asmcrypto.js',
'asmcrypto.js.map',
'test/aes.asm.js',
'test/aes.asm.js.map',
'doc/'
]
});
clean: [
'asmcrypto.js',
'asmcrypto.js.map',
'test/aes.asm.js',
'test/aes.asm.js.map',
'doc/',
],
});

grunt.registerTask('default', ['rollup:default', 'rollup:test_AES_ASM', 'uglify']);
grunt.registerTask('all', ['rollup:all']);
grunt.registerTask('esm', ['rollup:all_esm']);
grunt.registerTask('devel', ['rollup:all', 'rollup:test_AES_ASM', 'connect', 'watch']);
grunt.registerTask('test', ['connect', 'qunit']);
grunt.registerTask('default', ['rollup:default', 'rollup:test_AES_ASM', 'uglify']);
grunt.registerTask('all', ['rollup:all']);
grunt.registerTask('esm', ['rollup:all_esm']);
grunt.registerTask('devel', ['rollup:all', 'rollup:test_AES_ASM', 'connect', 'watch']);
grunt.registerTask('test', ['connect', 'shell']);
};
49 changes: 12 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
asmCrypto [![Build Status](https://travis-ci.org/vibornoff/asmcrypto.js.svg?branch=master)](https://travis-ci.org/vibornoff/asmcrypto.js) [![Selenium Test Status](https://saucelabs.com/buildstatus/vibornoff)](https://saucelabs.com/u/vibornoff) [![Join the chat at https://gitter.im/vibornoff/asmcrypto.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vibornoff/asmcrypto.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![CDNJS version](https://img.shields.io/cdnjs/v/asmCrypto.svg)](https://cdnjs.com/libraries/asmCrypto)
asmCrypto [![Build Status](https://travis-ci.org/asmcrypto/asmcrypto.js.svg?branch=master)](https://travis-ci.org/asmcrypto/asmcrypto.js) [![Join the chat at https://gitter.im/asmcrypto/asmcrypto.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/asmcrypto/asmcrypto.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
=========

JavaScript implementation of popular cryptographic utilities with performance in mind.
Expand All @@ -14,7 +14,6 @@ Add `<script src="path/to/asmcrypto.js"></script>` into your page.
Index
-----

* [Download](#download)
* [Build & Test](#build--test)
* [Performance](#performance)
* [API Reference](#api-reference)
Expand Down Expand Up @@ -47,15 +46,7 @@ Index
* [RSA-PSS-SHA256](#rsa_pss_sha256)
* [RSA-PSS-SHA512](#rsa_pss_sha512)
* [Cryptographically secure pseudorandom number generator](#cryptographically-secure-pseudorandom-number-generator)
* [Bugs & TODO](#bugs--todo)
* [Donate](#donate)

Download
--------

* [Minified JS file](http://vibornoff.com/asmcrypto.js) 130KB,
* [Source Map file](http://vibornoff.com/asmcrypto.js.map) 530KB,
* [All-in-One archive](http://vibornoff.com/asmcrypto.tar.gz) 216KB.

Build & Test
------------
Expand All @@ -66,36 +57,31 @@ Before you start check that [npm](http://npmjs.org/) is installed:

Then download and build the stuff:

git clone https://github.com/vibornoff/asmcrypto.js.git
git clone https://github.com/asmcrypto/asmcrypto.js.git
cd asmcrypto.js/
npm install

Running tests is always a good idea:

npm test

Congratulations! Now you have your `asmcrypto.js` and `asmcrypto.js.map` ready to use ☺
Congratulations! Now you have your `asmcrypto.js` ready to use ☺

Performance
-----------

In the development of this project, special attention was paid to the performance issues.
In the result of all the optimizations made this stuff is pretty fast under Firefox and Chrome.

My *Intel® Core™ i7-3770 CPU @ 3.40GHz* typical processing speeds are:
* *Chrome/31.0*
* SHA256: 51 MiB/s (**9 times faster** than *SJCL* and *CryptoJS*)
* AES-CBC: 47 MiB/s (**13 times faster** than *CryptoJS* and **20 times faster** than *SJCL*)
* *Firefox/26.0*
* SHA256: 144 MiB/s (**5 times faster** than *CryptoJS* and **20 times faster** than *SJCL*)
* AES-CBC: 81 MiB/s (**3 times faster** than *CryptoJS* and **8 times faster** than *SJCL*)

See benchmarks:
* [SHA256](http://jsperf.com/sha256/34),
* [HMAC-SHA256](http://jsperf.com/hmac-sha256/1),
* [PBKDF2-HMAC-SHA256](http://jsperf.com/pbkdf2-hmac-sha256/2),
* [AES](http://jsperf.com/aes/19),
* [Modular exponentiation (used internally in RSA)](http://jsperf.com/jsbn-vs-bigint-js-modular-exponentiation-montgomery/4).
Support
-----------

* NodeJS 8 and NodeJS 9
* IE11 (temporarily disabled, use previous versions: 0.16.x)
* last two Chrome versions
* last two Firefox versions and the latest Firefox ESR
* last two Edge versions
* last two Safari versions

API Reference
-------------
Expand Down Expand Up @@ -568,18 +554,7 @@ Allow implicitly-only seeded random output.

Disable implicit seeding warning when it's not desirable, e.g. at a unit test run.

Bugs & TODO
-----------

* Progressive operations are temporary fade out, they'll be back with WebCrypto API;
* Moar docs needed ☺

Not yet implemented:
* scrypt,
* dsa, ecdsa,
* rsa-pkcs-v1.5

Donate
------

If you like this stuff feel free to donate some funds to `1CiGzP1EFLTftqkfvVtbwvZ9Koiuoc4FSC`
Loading

0 comments on commit 59fa073

Please sign in to comment.