async function retParam(verifyText, signature, certificate){
    
    const hash = await sha256(verifyText);
    
    return {"hash":hash, "signature":signature, "certificate":certificate};
}

async function send(command){
    alert(JSON.stringify(command));
    $.post(PkcsApp + "verify",command,function(data) {
        $("#verification").text(data);
    });
}


function verifyRequest(e){
    e.preventDefault();
    verifyText = $("#toVerify").val();
    signature = $("#signature").val();
    certificate = $("#certificate").val();
    
    $("#verification").text("Verifying, please wait...");
    
    retParam(verifyText, signature, certificate).then(send);
   // event.preventDefault(); //we don t have to refill form
}


$( document ).ready(function() {
    
    $("#verify").submit(verifyRequest);
    
});

