Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
929 additions
and
896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service_name: travis-pro | ||
repo_token: hyvwZkspK1ws6HKgUD4IWbzowpfRYITgC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: node_js | ||
|
||
repo_token: hyvwZkspK1ws6HKgUD4IWbzowpfRYITgC | ||
|
||
node_js: | ||
|
||
- 0.10.35 | ||
- 4.4.5 | ||
- 6.2.0 | ||
|
||
services: | ||
- redis | ||
|
||
script: npm test | ||
|
||
after_script: npm run cov | ||
|
||
after_success: | ||
"curl -L -l https://coveralls.io/repos/github/navyxie/redlock-node/badge.svg?branch=master" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
var crypto = require('crypto'); | ||
function encrypt(plaintext,key,algorithm,iv,encode,digest){ | ||
var encData = ''; | ||
try{ | ||
algorithm = algorithm || "aes-128-ecb"; | ||
iv = iv || ''; | ||
encode = encode || 'utf8'; | ||
digest = digest || 'base64'; | ||
var cipher = crypto.createCipheriv(algorithm, key, iv); | ||
cipher.setAutoPadding(true); | ||
encData = cipher.update(plaintext,encode,digest); | ||
encData += cipher.final(digest); | ||
}catch(e){ | ||
console.error('aes encrypt data error : ',e); | ||
} | ||
return encData; | ||
var encData = ''; | ||
try{ | ||
algorithm = algorithm || "aes-128-ecb"; | ||
iv = iv || ''; | ||
encode = encode || 'utf8'; | ||
digest = digest || 'base64'; | ||
var cipher = crypto.createCipheriv(algorithm, key, iv); | ||
cipher.setAutoPadding(true); | ||
encData = cipher.update(plaintext,encode,digest); | ||
encData += cipher.final(digest); | ||
}catch(e){ | ||
console.error('aes encrypt data error : ',e); | ||
} | ||
return encData; | ||
} | ||
function decrypt(ciphertext,key,algorithm,iv,decode,digest){ | ||
var rawdata = ''; | ||
try{ | ||
algorithm = algorithm || "aes-128-ecb"; | ||
iv = iv || ''; | ||
decode = decode || 'hex'; | ||
digest = digest || 'utf8'; | ||
ciphertext = new Buffer(ciphertext,'base64'); | ||
var decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
rawdata = decipher.update(ciphertext,decode,digest); | ||
rawdata += decipher.final(digest); | ||
}catch(e){ | ||
console.error('aes decrypt data error : ',e); | ||
} | ||
return rawdata; | ||
var rawdata = ''; | ||
try{ | ||
algorithm = algorithm || "aes-128-ecb"; | ||
iv = iv || ''; | ||
decode = decode || 'hex'; | ||
digest = digest || 'utf8'; | ||
ciphertext = new Buffer(ciphertext,'base64'); | ||
var decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
rawdata = decipher.update(ciphertext,decode,digest); | ||
rawdata += decipher.final(digest); | ||
}catch(e){ | ||
console.error('aes decrypt data error : ',e); | ||
} | ||
return rawdata; | ||
} | ||
module.exports = { | ||
encrypt:encrypt, | ||
decrypt:decrypt, | ||
encrypt:encrypt, | ||
decrypt:decrypt, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
var crypto = require('crypto'); | ||
function encrypt(plaintext,key,algorithm,iv,encode,digest){ | ||
var encData = ''; | ||
try{ | ||
algorithm = algorithm || "des-ede3"; | ||
iv = iv || ''; | ||
encode = encode || 'utf8'; | ||
digest = digest || 'base64'; | ||
var cipher = crypto.createCipheriv(algorithm, key, iv); | ||
cipher.setAutoPadding(true); | ||
encData = cipher.update(plaintext,encode,digest); | ||
encData += cipher.final(digest); | ||
}catch(e){ | ||
console.error('des encrypt data error : ',e); | ||
} | ||
return encData; | ||
var encData = ''; | ||
try{ | ||
algorithm = algorithm || "des-ede3"; | ||
iv = iv || ''; | ||
encode = encode || 'utf8'; | ||
digest = digest || 'base64'; | ||
var cipher = crypto.createCipheriv(algorithm, key, iv); | ||
cipher.setAutoPadding(true); | ||
encData = cipher.update(plaintext,encode,digest); | ||
encData += cipher.final(digest); | ||
}catch(e){ | ||
console.error('des encrypt data error : ',e); | ||
} | ||
return encData; | ||
} | ||
function decrypt(ciphertext,key,algorithm,iv,decode,digest){ | ||
var rawdata = ''; | ||
try{ | ||
algorithm = algorithm || "des-ede3"; | ||
iv = iv || ''; | ||
decode = decode || 'hex'; | ||
digest = digest || 'utf8'; | ||
ciphertext = new Buffer(ciphertext,'base64'); | ||
var decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
rawdata = decipher.update(ciphertext,decode,digest); | ||
rawdata += decipher.final(digest); | ||
}catch(e){ | ||
console.error('des decrypt data error : ',e); | ||
} | ||
return rawdata; | ||
var rawdata = ''; | ||
try{ | ||
algorithm = algorithm || "des-ede3"; | ||
iv = iv || ''; | ||
decode = decode || 'hex'; | ||
digest = digest || 'utf8'; | ||
ciphertext = new Buffer(ciphertext,'base64'); | ||
var decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
rawdata = decipher.update(ciphertext,decode,digest); | ||
rawdata += decipher.final(digest); | ||
}catch(e){ | ||
console.error('des decrypt data error : ',e); | ||
} | ||
return rawdata; | ||
} | ||
module.exports = { | ||
encrypt:encrypt, | ||
decrypt:decrypt, | ||
encrypt:encrypt, | ||
decrypt:decrypt, | ||
} |
Oops, something went wrong.