fgl_hash()

fgl_hash() converts the character string specified as its 2nd parameter into the hash type specified as the 1st one.

Syntax

CALL fgl_hash(hash_type, string)

Parameters

hash_type

the type of the hash to be used for converting string

(can be a string of characters or a variable of the STRING data type)

string

the string to be converted into the specified type of hash

(can be a string of characters or a variable of the STRING data type)

Usage and examples

Simple programs given below show how the function can be used and what results it provides:

example code #1

MAIN

  DEFINEstrHashSTRING

    LETstrHash = fgl_hash("crc32", "1234567")

    DISPLAYstrHash

  CALLfgl_getkey()

END MAIN

example code #2

MAIN

  DEFINEstrHash, strValue, strHashAlgorithmNameSTRING

    LETstrValue = "1234567"

    LETstrHashAlgorithmName = "crc32"

    

    LETstrHash = fgl_hash(strHashAlgorithmName, strValue)

    DISPLAYstrHash

  CALLfgl_getkey()

END MAIN

obtained results #1-2

example code #3

MAIN

DEFINE strHash, strValue, strHashAlgorithmName STRING

DEFINE arrAllSupportedHashAlgorithmNames DYNAMIC ARRAY OF STRING

DEFINE i INT

LET arrAllSupportedHashAlgorithmNames = fgl_get_supported_hash_algorithms()

DISPLAY "supported hash algorithms are: ", arrAllSupportedHashAlgorithmNames

LET strValue = "12345"

DISPLAY "value: ", strValue

FOR i = 1 TO arrAllSupportedHashAlgorithmNames.getLength()

  LET strHashAlgorithmName = arrAllSupportedHashAlgorithmNames[ i]

  LET strHash = fgl_hash(strHashAlgorithmName, strValue)

  DISPLAY strHashAlgorithmName, ": ", strHash

END FOR

CALL fgl_getkey()

END MAIN

obtained results #3

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.