async function retParam(myText, signatureType)
{
    const hash = await sha256(myText);
    return {"hash":hash, "signatureType":signatureType}; 
    
}

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

function signRequest(e){
    e.preventDefault();
    $("#signature").text('Singing, please wait....');
    signText = $("#toSign").val();
    type = $("#alg").val();
    //alert(type); 
       
    retParam(signText, type).then(send);
}


$( document ).ready(function() {
    $("#sign").submit(signRequest);
});