• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
        • Hash Action Invoker Namespace
        • Hash.createHash Action
        • Hash.createMd5 Action
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Hash.createMd5 Action

Format
s = CS.Hash.createMd5(path := ... ‖ text := ... ‖ bytes := ...ʃ, bytesFormat := ...ʅ)
ArgumentDescriptionTypes / Required
pathThe path of a file to hash.string
not required
textA text string to hash.string
not required
bytesBytes to hash.string
not required
bytesFormatThe format of the bytes (if specifying bytes).
The default value is "autodetect".
string
not required
Description
The Hash.createMd5 action creates a MD5 hash based on the contents of a file, text, or bytes. One, and only one, of the arguments path, text, or bytes must be provided. If specifying text, the UTF-8 representation of the text is hashed. If specifying bytes, the optional bytesFormat argument dictates how binary data is converted from string format.
It is also possible to create MD5 hashes using the action Hash.createHash and specifying "MD5" as the type.
Return Value
The action returns a MD5 hash represented as a hexadecimal string. The 32-character hexadecimal characters are returned in lowercase.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form, if the file does not exist, or if the bytes value cannot be successfully converted from its binary format.
Example (CSPro Logic)
// see which images have not been synced, checking each MD5 against the list
// of previously synced MD5s stored in the persistent variable: previouslySyncedFileMd5s
persistent List string previouslySyncedFileMd5s;

List string imagePaths;
dirlist(imagePaths, ".", filter := "*.jpg");

do numeric ctr = 1 while ctr <= imagePaths.length()
   
string imageMd5 = CS.Hash.createMd5(path := imagePaths(ctr));

   
if previouslySyncedFileMd5s.seek(imageMd5) = 0 then
       
// ... the image has not been synced
    endif;
enddo;
See also: Hash Action Invoker Namespace, Hash.createHash Action