The data-hashing function

Before masking data was supported, the built-in hash function has been an alternative since Hive v1.3.0. A hash function reads an input string and produces a fixed-size alphanumeric output string. Since the output is generally uniquely (very little chance of collision) mapping to the input string, the hashed value is quite often used to secure columns, which are the unique identifiers for joining or comparing data. Built-in function, such as md5(...), sha1(...), and sha2(...), can be used for data hashing in HQL:

> SELECT 
> name,
> md5(name) as md5_name, -- 128 bit
> sha1(name) as sha1_name, -- 160 bit
> sha2(name, 256) as sha2_name -- 256 bit
> FROM employee;
+---------+----------------------------------+
| name | md5_name |
+---------+----------------------------------+
| Michael | 3e06fa3927cbdf4e9d93ba4541acce86 |
| Will | 2b80f09163f60ce1774b438e605eb1f9 |
| Shelley | e47e592945f28b3c3891ee9d27ec6b61 |
| Lucy | 80eb0e612760f756547b660c4c71ba7d |
+---------+----------------------------------+
+------------------------------------------+
| sha1_name |
+------------------------------------------+
| f8c38b2167c0ab6d7c720e47c2139428d77d8b6a |
| 3e3e5802bd4cad8e29e144b515307d8204a3202a |
| 2d4cab849437156354d24c9564958e6581711d08 |
| c5c8f32bdf9998e0f692231f4f969085c8dc225b |
+------------------------------------------+
+------------------------------------------------------------------+
| sha2_name |
+------------------------------------------------------------------+
| f089eaef57aba315bc0e1455985c0c8e40c247f073ce1f4c5a1f8ffde8773176 |
| 6cef4ccc1019d6cee6b9cad39d49cabf808ba2e0665d5832b70c44c09c2dfae0 |
| 1e8b342dde7c90cfbc9634c777b6b59388b6a4bd14274adffbfaeed4b329b26e |
| a3fa95a3b95d421c316f1a9b12c88edcc47896705976764d2652425de98f0c4f |
+------------------------------------------------------------------+
4 rows selected (0.344 seconds)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.43.26