require 'digest' module Ecoportal module API module Common module Content module StringDigest MAX_HASH_LABEL = 64 # Calculates the Hash of the field based on label def hash_label(str) return false unless str label = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL) return false unless label.length >= 3 return "z" + Digest::MD5.hexdigest(label).slice(0, 8); end end end end end end