
___x_cmd_hash_assert(){
    local fp="$1"
    local id="$2"

    local method=""
    case "${#id}" in
        32)     method=md5      ;;
        64)     method=sha256   ;;
        128)    method=sha512   ;;
        *)      return 2 ;; # Other code
    esac

    local value; value="$(___x_cmd_hash "$method" <"$fp")"
    local errcode=$?

    case "$errcode" in
        0)      [ "$value" = "$id" ]    ;;
        130)    return 130              ;;
        *)      return $errcode         ;;
    esac
}

___x_cmd_hash_verify(){
    local fp="$1"
    local id="$2"

    local method=""
    case "${#id}" in
        32)     method=md5      ;;
        64)     method=sha256   ;;
        128)    method=sha512   ;;
        *)      N=hash M="Unknown hash encoding -> ${#id}" log:ret:1
    esac

    local value; value="$(___x_cmd_hash "$method" <"$fp")"
    local errcode=$?

    case "$errcode" in
        0)      if [ "$value" = "$id" ]; then
                    hash:info   "[method=$method] File verification OK ->   $fp"
                else
                    hash:warn   "[method=$method] File verification failure ->   $fp"
                fi ;;
        130)    hash:info       "[method=$method] File verification Interrupted" ;;
        *)      hash:error      "[method=$method] File hashsum calculation failure ->   $fp" ;;
    esac

    return "$errcode"
}
