Refactor src/crypto/cipher/*.js to use import & export
This commit is contained in:
parent
60b23169ac
commit
19a97bf117
|
@ -511,4 +511,4 @@ export default {
|
|||
128: makeClass(128),
|
||||
192: makeClass(192),
|
||||
256: makeClass(256)
|
||||
}
|
||||
};
|
|
@ -395,7 +395,7 @@ Blowfish.prototype.init = function(key) {
|
|||
|
||||
// added by Recurity Labs
|
||||
|
||||
function BF(key) {
|
||||
export default function BF(key) {
|
||||
this.bf = new Blowfish();
|
||||
this.bf.init(key);
|
||||
|
||||
|
@ -403,8 +403,5 @@ function BF(key) {
|
|||
return this.bf.encrypt_block(block);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
module.exports = BF;
|
||||
module.exports.keySize = BF.prototype.keySize = 16;
|
||||
module.exports.blockSize = BF.prototype.blockSize = 16;
|
||||
BF.keySize = BF.prototype.keySize = 16;
|
||||
BF.blockSize = BF.prototype.blockSize = 16;
|
|
@ -592,7 +592,7 @@ function OpenpgpSymencCast5() {
|
|||
|
||||
}
|
||||
|
||||
function Cast5(key) {
|
||||
export default function Cast5(key) {
|
||||
this.cast5 = new OpenpgpSymencCast5();
|
||||
this.cast5.setKey(key);
|
||||
|
||||
|
@ -601,6 +601,5 @@ function Cast5(key) {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = Cast5;
|
||||
module.exports.blockSize = Cast5.prototype.blockSize = 8;
|
||||
module.exports.keySize = Cast5.prototype.keySize = 16;
|
||||
Cast5.blockSize = Cast5.prototype.blockSize = 8;
|
||||
Cast5.keySize = Cast5.prototype.keySize = 16;
|
|
@ -422,9 +422,9 @@ function OriginalDes(key) {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
/** @static */
|
||||
des: Des,
|
||||
/** @static */
|
||||
originalDes: OriginalDes
|
||||
};
|
||||
};
|
|
@ -8,8 +8,11 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import desModule from './des.js';
|
||||
import aes from'./aes.js';
|
||||
import desModule from './des.js';
|
||||
import cast5 from './cast5.js';
|
||||
import twofish from './twofish.js';
|
||||
import blowfish from './blowfish.js';
|
||||
|
||||
module.exports = {
|
||||
/** @see module:crypto/cipher/aes */
|
||||
|
@ -21,11 +24,11 @@ module.exports = {
|
|||
/** @see module:crypto/cipher/des.des */
|
||||
tripledes: desModule.des,
|
||||
/** @see module:crypto/cipher/cast5 */
|
||||
cast5: require('./cast5.js'),
|
||||
cast5: cast5,
|
||||
/** @see module:crypto/cipher/twofish */
|
||||
twofish: require('./twofish.js'),
|
||||
twofish: twofish,
|
||||
/** @see module:crypto/cipher/blowfish */
|
||||
blowfish: require('./blowfish.js'),
|
||||
blowfish: blowfish,
|
||||
/** Not implemented */
|
||||
idea: function() {
|
||||
throw new Error('IDEA symmetric-key algorithm not implemented');
|
||||
|
|
|
@ -329,7 +329,7 @@ function createTwofish() {
|
|||
|
||||
// added by Recurity Labs
|
||||
|
||||
function TF(key) {
|
||||
export default function TF(key) {
|
||||
this.tf = createTwofish();
|
||||
this.tf.open(toArray(key), 0);
|
||||
|
||||
|
@ -347,7 +347,5 @@ function toArray(typedArray) {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
module.exports = TF;
|
||||
module.exports.keySize = TF.prototype.keySize = 32;
|
||||
module.exports.blockSize = TF.prototype.blockSize = 16;
|
||||
TF.keySize = TF.prototype.keySize = 32;
|
||||
TF.blockSize = TF.prototype.blockSize = 16;
|
Loading…
Reference in New Issue
Block a user