Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Digest operators

crc32, md5 and rot13 from eZTemplateDigestOperator, plus sha1, which the class offers but which only works after another digest operator has loaded it; what they are for in templates and what not, with examples rendered…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/template-operators/digest-operators.md

On this page

Digest operators

Checksums and hashes of a string, for building ids, cache keys or class names. They are registered by eZTemplateDigestOperator (lib/eztemplate/classes/eztemplatedigestoperator.php) through lib/eztemplate/classes/eztemplateautoload.php. All work on the piped input and take no parameters.

Contents

  1. The operators
  2. sha1 and the autoload list
  3. What they are not for
  4. Related pages

The operators

md5

PHP md5(): 32 hex digits. Generated reference: md5.

crc32

eZSys::ezcrc32() (lib/ezutils/classes/ezsys.php): PHP crc32(), printed as an unsigned number when [SiteSettings] 64bitCompatibilityMode=enabled in site.ini, so the value is the same on 32-bit and 64-bit PHP. Generated reference: crc32.

rot13

PHP str_rot13(): every letter moved 13 places, other characters kept. It hides nothing; it only stops text from being read at a glance. Generated reference: rot13.

sha1

PHP sha1(): 40 hex digits. See the next section before using it.

All four: input the string (piped), no parameters, return a string (crc32 a number).

'Fit & Healthy'|md5 = {'Fit & Healthy'|md5}
'Fit & Healthy'|crc32 = {'Fit & Healthy'|crc32}
'Fit & Healthy'|rot13 = {'Fit & Healthy'|rot13}
'Fit & Healthy'|sha1 = {'Fit & Healthy'|sha1}

Output:

'Fit & Healthy'|md5 = 230d0ad476984ff3dba19ec739b09733
'Fit & Healthy'|crc32 = 2208743097
'Fit & Healthy'|rot13 = Svg & Urnygul
'Fit & Healthy'|sha1 = 2441fb64e95685d5f0064f97e86d06048e57a499

A short, stable id for an element, from a node of a development installation (node 89) and its current version:

{def $node = fetch( 'content', 'node', hash( 'node_id', 89 ) )}
id-{concat( $node.node_id, '-', $node.object.current_version )|md5|extract_left( 8 )}

Output:

id-0c7e77db

sha1 and the autoload list

The class adds sha1 to its operator list when PHP has the function, but the operator_names entry in lib/eztemplate/classes/eztemplateautoload.php lists only crc32, md5 and rot13. The engine loads an operator class at the first use of one of its listed names, and loading it registers every name the class offers. So sha1 works after md5, crc32 or rot13 has been used in the same request, as in the first example, and is "not registered" before that, leaving the value unchanged:

[{'Fit & Healthy'|sha1}]

Output:

[Fit & Healthy]

Logged by the template engine:

WARNING : Operator 'sha1' is not registered

Use md5 when you need a hash in a template, or register an operator of your own (Registering operators).

What they are not for

These are not for passwords, signatures or anything an attacker must not forge: MD5 and SHA-1 are broken for those purposes, and a template is the wrong place for secrets anyway. Use them for ids and cache keys only.

The examples gave the same output interpreted and compiled on a development installation.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x