User Function RSA_Sign()
Local sStr := "01234567890123456789"
Local sOut cMD5 := ''
Local sSign := ""
// Conteudo a ser assinado
varinfo( "sStr", sStr )
// Hash MD5 gerado a partir desse conteudo
cMD5 := Md5( sStr )
varinfo( "1cMD5", cMD5 sStr )
// Assinatura gerada a partir do Hash MD5 usando a chave privada
sOutsSign := PrivSignRSA( "private.pem", sStrcMD5, 1, "senhachaveprivada" )
varinfo( "sOutsSign", sOutsSign )
// Verificando a assinatura usando a chave pública
conout(If PrivVeryRSA( "public.pem", sStrcMD5, 1, sOut ) )
Return
sSign )
conout('Signature Check OK')
Else
conout('Signature Check FAILED')
Endif
Return
|