Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
1 year ago
|
var CipherBase = require('cipher-base')
|
||
|
var des = require('des.js')
|
||
|
var inherits = require('inherits')
|
||
|
var Buffer = require('safe-buffer').Buffer
|
||
|
|
||
|
var modes = {
|
||
|
'des-ede3-cbc': des.CBC.instantiate(des.EDE),
|
||
|
'des-ede3': des.EDE,
|
||
|
'des-ede-cbc': des.CBC.instantiate(des.EDE),
|
||
|
'des-ede': des.EDE,
|
||
|
'des-cbc': des.CBC.instantiate(des.DES),
|
||
|
'des-ecb': des.DES
|
||
|
}
|
||
|
modes.des = modes['des-cbc']
|
||
|
modes.des3 = modes['des-ede3-cbc']
|
||
|
module.exports = DES
|
||
|
inherits(DES, CipherBase)
|
||
|
function DES (opts) {
|
||
|
CipherBase.call(this)
|
||
|
var modeName = opts.mode.toLowerCase()
|
||
|
var mode = modes[modeName]
|
||
|
var type
|
||
|
if (opts.decrypt) {
|
||
|
type = 'decrypt'
|
||
|
} else {
|
||
|
type = 'encrypt'
|
||
|
}
|
||
|
var key = opts.key
|
||
|
if (!Buffer.isBuffer(key)) {
|
||
|
key = Buffer.from(key)
|
||
|
}
|
||
|
if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
|
||
|
key = Buffer.concat([key, key.slice(0, 8)])
|
||
|
}
|
||
|
var iv = opts.iv
|
||
|
if (!Buffer.isBuffer(iv)) {
|
||
|
iv = Buffer.from(iv)
|
||
|
}
|
||
|
this._des = mode.create({
|
||
|
key: key,
|
||
|
iv: iv,
|
||
|
type: type
|
||
|
})
|
||
|
}
|
||
|
DES.prototype._update = function (data) {
|
||
|
return Buffer.from(this._des.update(data))
|
||
|
}
|
||
|
DES.prototype._final = function () {
|
||
|
return Buffer.from(this._des.final())
|
||
|
}
|