Example:
var Crypto = Ext.create('Ext.util.Crypto'); /*** MD5 */ var digest_md5 = Crypto.MD5("message"); /*** SHA1 */ var digest_sha1 = Crypto.SHA1("message"); /*** SHA224 */ var digest_sha224 = Crypto.SHA224("message"); /*** SHA256 */ var digest_sha256 = Crypto.SHA256("message"); /*** SHA384 */ var digest_sha384 = Crypto.SHA384("message"); /*** SHA512 */ var digest_sha512 = Crypto.SHA512("message");
Library:
Ext.define('Ext.util.Crypto', { /** * @cfg {String} [id] * An identifier by which this Filter is indexed in a {@link Ext.data.Store#property-filters Store's filters collection} * * Identified Filters may be individually removed from a Store's filter set by using {@link Ext.data.Store#removeFilter}. * * Anonymous Filters may be removed en masse by passing `null` to {@link Ext.data.Store#removeFilter}. */ id: null, /** * @cfg {Boolean} anyMatch * True to allow any match - no regex start/end line anchors will be added. */ anyMatch: false, /** * @cfg {Boolean} exactMatch * True to force exact match (^ and $ characters added to the regex). Ignored if anyMatch is true. */ exactMatch: false, /** * @cfg {Boolean} caseSensitive * True to make the regex case sensitive (adds 'i' switch to regex). */ caseSensitive: false, /** * @property {Boolean} disabled * Setting this property to `true` disables this individual Filter so that it no longer contributes to a {@link Ext.data.Store#property-filters Store's filter set} * * When disabled, the next time the store is filtered, the Filter plays no part in filtering and records eliminated by it may rejoin the dataset. * */ disabled: false, /** * @cfg {String} [operator] * The operator to use to compare the {@link #cfg-property} to this Filter's {@link #cfg-value} * * Possible values are: * * < * * <= * * = * * >= * * > * * != */ operator: null, /** * @cfg {String} root * Optional root property. This is mostly useful when filtering a Store, in which case we set the root to 'data' to * make the filter pull the {@link #property} out of the data object of each item */ statics: { /** * Creates a single filter function which encapsulates the passed Filter array. * @param {Ext.util.Filter[]} filters The filter set for which to create a filter function * @return {Function} a function, which when passed a candidate object returns `true` if * the candidate passes all the specified Filters. */ createFilterFn: function(filters) { return filters && filters.length ? function(candidate) { var isMatch = true, length = filters.length, i, filter; for (i = 0; isMatch && i < length; i++) { filter = filters[i]; // Disabling a filter stops it from contributing to the overall filter function. if (!filter.disabled) { isMatch = isMatch && filter.filterFn.call(filter.scope || filter, candidate); } } return isMatch; } : function() { return true; }; } }, /** * Creates new Filter. * @param {Object} [config] Config object */ constructor: function(config) { var me = this; me.initialConfig = config; Ext.apply(me, config); }, /** * @private * Returns the root property of the given item, based on the configured {@link #root} property * @param {Object} item The item * @return {Object} The root property of the object */ MD5: function(message) { return CryptoJS.MD5(message); }, SHA1: function(message) { return CryptoJS.SHA1(message); }, SHA224: function(message) { return CryptoJS.SHA224(message); }, SHA256: function(message) { return CryptoJS.SHA256(message); }, SHA384: function(message) { return CryptoJS.SHA384(message); }, SHA512: function(message) { return CryptoJS.SHA512(message); }, });
The hash functions available are:
- MD5
- SHA-1
- SHA-256
- SHA-384
- SHA-512
The hash (SHA-3) functions available are:
- 224
- 256
- 384
- 512 (the default)