View Full Version : Class AES, RSA, SHA, Base64 for Ext JS 4

19 Nov 2011, 3:25 PM

I'm looking for some javascript class for AES (128 and 256), RSA, SHA (SHA1, SHA256), Base64 compatible with Ext JS 4.
The most part of what I found on the Internet is either incomplete or not very nice.

Any suggestion will be appreciate

19 Nov 2011, 5:51 PM
Since most of them are going to be pieced together, I would create a class that you can port these to and have a single entry point...

Ext.define('MyApp.util.Encrypt', {
singleton : true,

encrypt: function(value, type) {
type = (type || 'aes').toLowerCase();

return this[type](value);

aes : function(value) {
//do aes encryption here

rsa : function(value) {
//do rsa encryption here

sha : function(value) {
//do sha encryption here

base64 : function(value) {
//do base64 encryption here

Then you can call it by doing:

MyApp.util.Encrypt.encrypt('encrypt me', 'base64');

20 Nov 2011, 8:05 AM
Thanks Mitchell for you answer but I already created some empty class with Ext.define.

The question is more what is the best javascript classes or javascript framework for AES, RSA, SHA and Base64? And, because they are not Ext JS class, how I can load them dynamically?

20 Nov 2011, 9:00 AM
One reason you may be finding it difficult to track down good JavaScript implementations of encryption algorithms is that it is difficult to think of a genuine use case. I've never seen such a use case for client-side JavaScript, invariably https proves to be a better solution as over-the-wire traffic is the only thing that makes sense to encrypt.

Lumping base64 encoding in with encryption algorithms always leaves me a bit suspicious too.

I would imagine that the rising popularity of NodeJS is likely to see some advances in this area as it's much easier to think of use cases for encryption in that environment. I know that base64 encoding is built in at a pretty fundamental level.