better error check
merge internal signText and signAndEncrypt methods
add integrity check