datafusion_functions/crypto/
mod.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! "crypto" DataFusion functions
19
20use datafusion_expr::ScalarUDF;
21use std::sync::Arc;
22
23pub mod basic;
24pub mod digest;
25pub mod md5;
26pub mod sha224;
27pub mod sha256;
28pub mod sha384;
29pub mod sha512;
30make_udf_function!(digest::DigestFunc, digest);
31make_udf_function!(md5::Md5Func, md5);
32make_udf_function!(sha224::SHA224Func, sha224);
33make_udf_function!(sha256::SHA256Func, sha256);
34make_udf_function!(sha384::SHA384Func, sha384);
35make_udf_function!(sha512::SHA512Func, sha512);
36
37pub mod expr_fn {
38    export_functions!((
39        digest,
40        "Computes the binary hash of an expression using the specified algorithm.",
41        input_arg1 input_arg2
42    ),(
43        md5,
44        "Computes an MD5 128-bit checksum for a string expression.",
45        input_arg
46    ),(
47        sha224,
48        "Computes the SHA-224 hash of a binary string.",
49        input_arg1
50    ),(
51        sha256,
52        "Computes the SHA-256 hash of a binary string.",
53        input_arg1
54    ),(
55        sha384,
56        "Computes the SHA-384 hash of a binary string.",
57        input_arg1
58    ),(
59        sha512,
60        "Computes the SHA-512 hash of a binary string.",
61        input_arg1
62    ));
63}
64
65/// Returns all DataFusion functions defined in this package
66pub fn functions() -> Vec<Arc<ScalarUDF>> {
67    vec![digest(), md5(), sha224(), sha256(), sha384(), sha512()]
68}