Example of implementation with PHP

Example of a signature computation using the HMAC-SHA-256 algorithm:

function getSignature ($params,$key)
{
    /**
     *Function that computes the signature.
     * $params : table containing the fields to send in the payment form.
     * $key : TEST or PRODUCTION key
     */
    //Initialization of the variable that will contain the string to encrypt
    $contenu_signature = "";

    //sorting fields alphabetically
    ksort($params);
    foreach($params as $name=>$value){

        //Recovery of vads_ fields 
        if (substr($nom,0,5)=='vads_'){

            //Concatenation with "+"
            $contenu_signature .= $value."+";
         }
    }
    //Adding the key at the end
    $contenu_signature .= $key;

    //Encoding base64 encoded chain with SHA-256 algorithm
    $signature = base64_encode(hash_hmac('sha256',$contenu_signature, $key, true));
    return $signature;
 }	            

Example of a signature computation using the SHA-1 algorithm:

function getSignature($params, $key)
{
    /**
     * Function that computes the signature.
     * $params : table containing the fields to send in the payment form.
     * $key : TEST or  PRODUCTION key
     */
    //Initialization of the variable that will contain the string to encrypt
    $contenu_signature = "" ;

    // Sorting fields alphabetically
    ksort($params);
        foreach ($params as $name =>$value)
    { 
    // Recovery of vads_ fields 
        if (substr($nom,0,5)=='vads_') { 
            // Concatenation with "+"
            $contenu_signature .= $value."+";
        }
    }
    // Adding the key at the end
    $contenu_signature .= $key;
    
    // Applying SHA-1 algorithm
    $signature = sha1($contenu_signature);
    return $signature ;
}