Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ChecksumUtils

example

var checksumUtils = require('mmirf/checksumUtils').init();

Hierarchy

  • ChecksumUtils

Index

Methods

createContent

  • createContent(originalText: string, additionalInfo?: string): string
  • 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

    • originalText: string
                          the "raw" text for which to generate the checksum information
      
    • Optional additionalInfo: string

    Returns string

    the checksum information as a String (formatted as content of a checksum file)

getConentSeparator

  • getConentSeparator(): string
  • The Char used for separating fields within checksum files.

    Returns string

    the separator char (TAB)

getFileExt

  • getFileExt(): string
  • Returns the file extension for checksum-files.

    Returns string

    the default file extension for checksum files (including the separating dot, eg. ".checksum.txt")

init

  • Must be called before using checksum-generation: sets/initializes the object/function for checksum generation.

    After first call, following calls to this function will have no effect.

    Parameters

    Returns void

isSame

  • isSame(rawTextContent: string, referenceHash: string | ChecksumInfo, additionalInfo?: string): boolean
  • 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.

    function

    Parameters

    • rawTextContent: string
                      the (raw) text/content which should be checked
      
    • referenceHash: string | ChecksumInfo
                      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:
                      <pre>{ size: INTEGER, hash: STRING, info?: STRING }</pre>
      
    • Optional additionalInfo: string

    Returns boolean

                    <code>true</code> if the raw content matches the hash
    

parseContent

  • Parses the raw text-content of a checksum file and returns an object with properties:

    Parameters

    • rawTextContent: string
                      the raw conent of a checksum file
      

    Returns ChecksumInfo

    an object with the extracted properties from the checksum-data:

    { size: INTEGER, hash: STRING, info?: STRING }

Generated using TypeDoc