<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Hashing Functions and Examples on</title><link>https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/</link><description>Recent content in Hashing Functions and Examples on</description><generator>Hugo</generator><language>en</language><atom:link href="https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/index.xml" rel="self" type="application/rss+xml"/><item><title>Hash Data column size</title><link>https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/pmr_ch_appendix_e_using_hash_data_column_size/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/pmr_ch_appendix_e_using_hash_data_column_size/</guid><description>&lt;p>A hash value is always 160 bits / 20 bytes (SHA1) or 256 bits / 32 bytes (SHA256) long regardless of what data it&amp;rsquo;s calculated on. Basically you should have a table with a binary column of 20 bytes or 32 bytes for the hash value.&lt;/p>
&lt;p>Here is an example of an Oracle table with hash value instead of name:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>CREATE TABLE NAMETABLE ( ident NUMBER PRIMARY KEY, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> name RAW(32));
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Using Hashing Triggers and View</title><link>https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/pmr_ch_appendix_e_using_hashing_triggers_and_view/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.protegrity.com/protectors/10.1/docs/pmr/pmr_ch_appendix_e_hashing_functions_and_examples/pmr_ch_appendix_e_using_hashing_triggers_and_view/</guid><description>&lt;p>Oracle example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span>CREATE OR REPLACE TRIGGER SCOTT.NAMETABLE_INS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INSTEAD OF INSERT ON SCOTT.NAMETABLE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>FOR EACH ROW
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>DECLARE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME_ RAW(2000) := NULL;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>BEGIN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> **NAME\_:=PTY.INS\_HASH\_VARCHAR2\(&amp;#39;HashDE&amp;#39;, :new.NAME, 0\)**;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> INSERT INTO SCOTT.NAMETABLE_ENC(IDENT, NAME)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> VALUES(:new.IDENT, NAME_);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>END;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CREATE OR REPLACE TRIGGER SCOTT.NAMETABLE_UPD
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>INSTEAD OF UPDATE ON SCOTT.NAMETABLE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>FOR EACH ROW
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>DECLARE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME_ RAW(2000) := NULL;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>BEGIN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> **PTY.SEL\_CHECK\(&amp;#39;HashDE&amp;#39;\);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> NAME\_:=PTY.UPD\_HASH\_VARCHAR2\(&amp;#39;HashDE&amp;#39;, :new.NAME, 0\)**;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> IF: old.IDENT = :new.IDENT THEN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> UPDATE NAMETABLE_ENC SET 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> NAME= NAME_,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> WHERE IDENT=:old.IDENT;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ELSE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> UPDATE NAMETABLE_ENC SET 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> IDENT=:new.IDENT, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> NAME= NAME_,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> WHERE IDENT=:old.IDENT;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> END IF;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>END;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The view selects the hash value directly from the table instead of running a decrypt function. To make this work as a normal trigger/view solution, the binary data type is cast into the original data type. In Oracle it should be VARCHAR2. The data type must be cast to insert data through the view as usual.&lt;/p></description></item></channel></rss>