All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core_functions_unclassified.hash.hash.pure Maven / Gradle / Ivy

There is a newer version: 4.67.9
Show newest version
// Copyright 2022 Goldman Sachs
//
// Licensed 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
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import meta::pure::functions::hash::*;

Enum meta::pure::functions::hash::HashType
{
    MD5,
    SHA1,
    SHA256
}

native function meta::pure::functions::hash::hash(text: String[1], hashType: meta::pure::functions::hash::HashType[1]):String[1];


function <> meta::pure::functions::hash::tests::testMD5_Hash():Boolean[1]
{
   assertEquals('65A8E27D8879283831B664BD8B7F0AD4'->toLower(), hash('Hello, World!', HashType.MD5));
}

function <> meta::pure::functions::hash::tests::testSHA1_Hash():Boolean[1]
{
   assertEquals('0A0A9F2A6772942557AB5355D76AF442F8F65E01'->toLower(), hash('Hello, World!', HashType.SHA1));
}

function <> meta::pure::functions::hash::tests::testSHA256_Hash():Boolean[1]
{
   assertEquals('DFFD6021BB2BD5B0AF676290809EC3A53191DD81C7F70A4B28688A362182986F'->toLower(), hash('Hello, World!', HashType.SHA256));
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy