Commit 8594d3f0 authored by Tristan Cavelier's avatar Tristan Cavelier

revision generation method added to storage.js

parent f20bd74c
...@@ -14,6 +14,29 @@ var storage = function(spec, my) { ...@@ -14,6 +14,29 @@ var storage = function(spec, my) {
} }
}); });
/**
* Generates a hash code of a string
* @method hashCode
* @param {string} string The string to hash
* @return {string} The string hash code
*/
that.hashCode = function (string) {
return hex_sha256(string);
};
/**
* Generates the next revision of [previous_revision]. [string] helps us
* to generate a hash code.
* @methode generateNextRev
* @param {string} previous_revision The previous revision
* @param {string} string String to help generate hash code
* @return {array} 0:The next revision number and 1:the hash code
*/
that.generateNextRevision = function (previous_revision, string) {
return [parseInt(previous_revision.split('-')[0],10)+1,
utilities.hashCode(previous_revision + string)];
};
/** /**
* Creates the error object for all errors * Creates the error object for all errors
* @method createErrorObject * @method createErrorObject
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment