filer/src/shared.js

25 lines
491 B
JavaScript
Raw Normal View History

2013-05-31 01:38:44 +00:00
define(function(require) {
require("crypto-js/rollups/sha256"); var Crypto = CryptoJS;
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
}).toUpperCase();
}
2013-05-31 01:38:44 +00:00
function hash(string) {
return Crypto.SHA256(string).toString(Crypto.enc.hex);
}
2013-05-31 01:38:44 +00:00
function nop() {}
2013-05-31 01:38:44 +00:00
return {
guid: guid,
hash: hash,
nop: nop
2013-05-31 01:38:44 +00:00
};
});