[ 
https://issues.apache.org/jira/browse/DRILL-5634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16072201#comment-16072201
 ] 

ASF GitHub Bot commented on DRILL-5634:
---------------------------------------

Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/865#discussion_r125246241
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCryptoFunctions.java
 ---
    @@ -0,0 +1,91 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.drill.exec.fn.impl;
    +
    +import org.apache.drill.BaseTestQuery;
    +import org.junit.Test;
    +
    +public class TestCryptoFunctions extends BaseTestQuery {
    +
    +    @Test
    +    public void testMD5() throws Exception {
    +        final String query = "select md5( 'testing' ) as md5_hash from 
(values(1))";
    +        testBuilder()
    +            .sqlQuery(query)
    +            .ordered()
    +            .baselineColumns("md5_hash")
    +            .baselineValues("ae2b1fca515949e5d54fb22b8ed95575")
    +            .go();
    +    }
    +
    +    @Test
    +    public void testSHA1() throws Exception {
    +        final String query = "select sha( 'testing' ) as sha_hash from 
(values(1))";
    --- End diff --
    
    Please remove extra space here and in test below: `sha( 'testing' ) ` -> 
`sha('testing') `


> Add Crypto and Hash Functions
> -----------------------------
>
>                 Key: DRILL-5634
>                 URL: https://issues.apache.org/jira/browse/DRILL-5634
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Functions - Drill
>    Affects Versions: 1.10.0
>            Reporter: Charles Givre
>              Labels: doc-impacting
>             Fix For: 1.11.0
>
>
> This library contains a collection of cryptography-related functions for 
> Apache Drill. It generally mirrors the crypto functions in MySQL.  The 
> package includes:
> * **`aes_encrypt()`/ `aes_decrypt()`**: implement encryption and decryption 
> of data using the official AES (Advanced Encryption Standard) algorithm, 
> previously known as “Rijndael.”
>  `AES_ENCRYPT()` encrypts the string `str` using the key string `key_str` and 
> returns a binary string containing the encrypted output. `AES_DECRYPT()` 
> decrypts the encrypted string `crypt_str` using the key string `key_str` and 
> returns the original cleartext string. If either function argument is NULL, 
> the function returns NULL.
> ```sql
> > SELECT aes_encrypt( 'encrypted_text', 'my_secret_key' ) AS aes FROM 
> > (VALUES(1));
> +---------------------------+
> |            aes            |
> +---------------------------+
> | JkcBUNAn8ByKWCcVmNrKMA==  |
> +---------------------------+
>  > SELECT aes_encrypt( 'encrypted_text', 'my_secret_key' ) AS encrypted,
>  aes_decrypt(aes_encrypt( 'encrypted_text', 'my_secret_key' 
> ),'my_secret_key') AS decrypted 
>  FROM (VALUES(1));
> +---------------------------+-----------------+
> |         encrypted         |    decrypted    |
> +---------------------------+-----------------+
> | JkcBUNAn8ByKWCcVmNrKMA==  | encrypted_text  |
> +---------------------------+-----------------+
> ```
> * **`md5(<text>)`**:  Returns the md5 hash of the text. 
> (https://en.wikipedia.org/wiki/MD5)
> Usage:
> ```sql
> > select md5( 'testing' ) from (VALUES(1));
> +-----------------------------------+
> |              EXPR$0               |
> +-----------------------------------+
> | ae2b1fca515949e5d54fb22b8ed95575  |
> +-----------------------------------+
> ```
> * **`sha(<text>`) / `sha1(<text>)`**: Calculates an SHA-1 160-bit checksum 
> for the string, as described in RFC 3174 (Secure Hash Algorithm). 
> (https://en.wikipedia.org/wiki/SHA-1)  The value is returned as a string of 
> 40 hexadecimal digits, or NULL if the argument was NULL. Note that `sha()` 
> and `sha1()` are aliases for the same function. 
> ```sql
> > select sha1( 'testing' ) from (VALUES(1));
> +-------------------------------------------+
> |                  EXPR$0                   |
> +-------------------------------------------+
> | dc724af18fbdd4e59189f5fe768a5f8311527050  |
> +-------------------------------------------+
> ```
> * **`sha2(<text>`) / `sha256(<text>)`**: Calculates an SHA-2 256-bit checksum 
> for the string. (https://en.wikipedia.org/wiki/SHA-2)  The value is returned 
> as a string of hexadecimal digits, or NULL if the argument was NULL. Note 
> that `sha2()` and `sha256()` are aliases for the same function. 
> ```sql
> > select sha2( 'testing' ) from (VALUES(1));
> +-------------------------------------------------------------------+
> |                              EXPR$0                               |
> +-------------------------------------------------------------------+
> | cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90  |
> +-------------------------------------------------------------------+
> ```
> Additionally, there are also `sha384(<text>)` and `sha512(<text>)` functions 
> which return SHA-2 hashes with 384 and 512 bit checksums.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to