feature(sha) add

This commit is contained in:
coderaiser 2014-10-27 06:52:50 -04:00
parent 3f4340ecb7
commit ee5c15b901
3 changed files with 1591 additions and 1 deletions

View file

@ -368,6 +368,23 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
});
}
function sha(callback) {
var dir = CloudCmd.LIBDIR,
url = dir + 'sha/jsSHA.js';
DOM.load.js(url, function() {
var shaObj, hash, error,
value = Ace.getValue();
error = Util.exec.try(function() {
shaObj = new window.jsSHA(value, 'TEXT');
hash = shaObj.getHash('SHA-1', 'HEX');
});
callback(error, hash);
});
}
function setJsHintConfig(callback) {
var JSHINT_PATH = CloudCmd.PREFIX + '/.jshintrc',
func = function() {
@ -481,7 +498,14 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
if (!isError) {
Edit.showMessage(text);
DOM.saveDataToStorage(path, Value);
sha(function(error, hash) {
if (error)
Util.log(error);
DOM.saveDataToStorage(path, Value, hash);
});
DOM.setCurrentSize(size);
} else {
ret = Dialog.confirm(text + msg);

1527
lib/sha/jsSHA.js Normal file

File diff suppressed because it is too large Load diff

39
lib/sha/package.json Normal file
View file

@ -0,0 +1,39 @@
{
"name": "jssha",
"version": "2.0.0",
"description": "jsSHA is a JavaScript implementation of the entire family of SHA hashes as defined in FIPS 180-2 (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) as well as HMAC",
"main": "src/sha.js",
"repository": {
"type": "git",
"url": "https://github.com/Caligatio/jsSHA.git"
},
"keywords": [
"SHA-1",
"SHA-256",
"SHA-224",
"SHA-384",
"SHA-512",
"SHA1",
"SHA256",
"SHA224",
"SHA384",
"SHA512",
"SHA2",
"HMAC",
"hash"
],
"license": "BSD",
"author": "Brian Turek <brian.turek@gmail.com>",
"bugs": {
"url": "https://github.com/Caligatio/jsSHA/issues"
},
"engines": {
"node": "*"
},
"homepage": "https://github.com/Caligatio/jsSHA",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}