Sha256: c8ef0ca3bf2c33afa776bc68f588742dc146a9bd784d9f39e9f5617f522428d3
Contents?: true
Size: 733 Bytes
Versions: 33
Compression:
Stored size: 733 Bytes
Contents
require 'digest' module Ecoportal module API module Common module Content module StringDigest MAX_HASH_LABEL = 64 def indexable_label(str, any_length: false) return nil unless str lbl = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL) return nil if (lbl.length < 3) && !any_length lbl end # Calculates the Hash of the field based on label def hash_label(str, any_length: false) return nil unless lbl = indexable_label(str, any_length: any_length) "z" + Digest::MD5.hexdigest(lbl).slice(0, 8); end end end end end end
Version data entries
33 entries across 33 versions & 1 rubygems