Namespace mmir.tools.ChecksumUtils
Defined in: checksumUtils.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A Utility class for creating / reading checksum (files).
|
Method Attributes | Method Name and Description |
---|---|
ChecksumUtils#createContent(originalText)
Creates the content for a checksum file, containing information about
the size and hash-value for the supplied String argument.
|
|
The Char used for separating fields within checksum files.
|
|
Returns the file extension for checksum-files.
|
|
ChecksumUtils#init(cryptoImpl)
Must be called before using checksum-generation:
sets/initializes the object/function for checksum generation.
|
|
ChecksumUtils#isSame(rawTextContent, referenceHash)
Check if the length / checksum for a raw text is the same as the checksum-information.
|
|
ChecksumUtils#parseContent(rawTextContent)
Parses the raw text-content of a checksum file and returns an object
with properties:
{ size: INTEGER, hash: STRING } |
Namespace Detail
mmir.tools.ChecksumUtils
A Utility class for creating / reading checksum (files).
- Requires:
- CryptoJS (MD5, see https://code.google.com/p/crypto-js/)
Method Detail
{String}
ChecksumUtils#createContent(originalText)
Creates the content for a checksum file, containing information about
the size and hash-value for the supplied String argument.
The result can be "written as is" to a file.
- Parameters:
- {String} originalText
- the "raw" text for which to generate the checksum information
- Returns:
- {String} the checksum information as a String (formatted as content of a checksum file)
{String}
ChecksumUtils#getConentSeparator()
The Char used for separating fields within checksum files.
- Returns:
- {String} the separator char (TAB)
{String}
ChecksumUtils#getFileExt()
Returns the file extension for checksum-files.
CONST
- Returns:
- {String} the default file extension for checksum files (including the separating dot, eg. ".checksum.txt")
ChecksumUtils#init(cryptoImpl)
Must be called before using checksum-generation:
sets/initializes the object/function for checksum generation.
- Parameters:
- {CryptoJS} cryptoImpl Optional
- OPTIONAL
if omitted, the (global!) variable
CryptoJS
is used by default. This argument should be the CryptoJS object containing the MD5 function/algorithm, i.e. CryptoJS.MD5() must be a function!
{Boolean}
ChecksumUtils#isSame(rawTextContent, referenceHash)
Check if the length / checksum for a raw text is the same as the checksum-information.
NOTE: The actual checksum for the raw text is only generated & checked, if the size is equal.
- Parameters:
- {String} rawTextContent
- the (raw) text/content which should be checked
- {String|PlainObject} referenceHash
- the checksum information to check against: either the raw content (String) of a checksum file, or the parsed contents of a checksum file, which is a PlainObject with properties: { size: INTEGER, hash: STRING }
- Returns:
- {Boolean}
true
if the raw content matches the hash
{PlainObject}
ChecksumUtils#parseContent(rawTextContent)
Parses the raw text-content of a checksum file and returns an object
with properties:
{ size: INTEGER, hash: STRING }
- Parameters:
- {String} rawTextContent
- the raw conent of a checksum file
- Returns:
- {PlainObject} an object with the extracted properties from the checksum-data: { size: INTEGER, hash: STRING }