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 sha;
27make_udf_function!(digest::DigestFunc, digest);
28make_udf_function!(md5::Md5Func, md5);
29make_udf_function!(sha::SHAFunc, sha224, sha::SHAFunc::sha224);
30make_udf_function!(sha::SHAFunc, sha256, sha::SHAFunc::sha256);
31make_udf_function!(sha::SHAFunc, sha384, sha::SHAFunc::sha384);
32make_udf_function!(sha::SHAFunc, sha512, sha::SHAFunc::sha512);
33
34pub mod expr_fn {
35    export_functions!((
36        digest,
37        "Computes the binary hash of an expression using the specified algorithm.",
38        input_arg1 input_arg2
39    ),(
40        md5,
41        "Computes an MD5 128-bit checksum for a string expression.",
42        input_arg
43    ),(
44        sha224,
45        "Computes the SHA-224 hash of a binary string.",
46        input_arg1
47    ),(
48        sha256,
49        "Computes the SHA-256 hash of a binary string.",
50        input_arg1
51    ),(
52        sha384,
53        "Computes the SHA-384 hash of a binary string.",
54        input_arg1
55    ),(
56        sha512,
57        "Computes the SHA-512 hash of a binary string.",
58        input_arg1
59    ));
60}
61
62/// Returns all DataFusion functions defined in this package
63pub fn functions() -> Vec<Arc<ScalarUDF>> {
64    vec![digest(), md5(), sha224(), sha256(), sha384(), sha512()]
65}