RE:MD5, cadena original, sello digital
Publicado por
David Duran (1 intervención) el 16/12/2010 18:34:44
Con estas lineas generas el sello
//Obteniendo la llave desde el archivo *.key
ll_keyprivada= RSA_ReadEncPrivateKeys (ls_aux,0, as_filellave,ls_pass, 0)
IF ll_keyprivada > 0 THEN
ls_keyprivada=Fill ( " ", ll_keyprivada )
//Encriptacion de cadena_original con llave privada
lb_info=blob(as_cadena_original,EncodingUTF8!)
ll_len_info = len(lb_info)
RSA_ReadEncPrivateKeys (ls_keyprivada,ll_keyprivada, as_filellave,ls_pass, 0)
ll_len_bloque = RSA_KeyBytes(ls_keyprivada)
//Creo bloque de mensaje codificado
ll_tamanio = RSA_EncodeMsg(lb_bloque, ll_len_bloque, lb_info, ll_len_info, 32 + 1)
//Combinacion del bloque con el string de la llave
RSA_RawPrivate(lb_bloque, ll_len_bloque, ls_keyprivada, 0)
//Conversion a base64
ll_tamanio = len(lb_bloque)
nB64Len = CNV_B64StrFromBytes(ls_sello, 0, lb_bloque, ll_tamanio)
ls_Sello = fill(" ",nB64Len)
CNV_B64StrFromBytes(ls_sello, nB64Len, lb_bloque, ll_tamanio)
//Funciones Globales
Function long RSA_ReadEncPrivateKeys (REF string strPrivateKey,long nKeyMaxLen, string strEpkFileName,string strPassword, long nOptions) Library "diCrPKI.dll" alias for "RSA_ReadEncPrivateKey;ansi"
Function integer RSA_KeyBytes (string strKey) Library "diCrPKI.dll" alias for "RSA_KeyBytes;ansi"
Function integer RSA_EncodeMsg (Ref blob abOutput, integer nOutputLen, REF blob abMessage, integer nMsgLen, integer nOptions) Library "diCrPKI.dll" alias for "RSA_EncodeMsg;ansi"
Function integer RSA_DecodeMsg(Ref blob abOutput, integer nOutputLen, REF blob abMessage, integer nMsgLen, integer nOptions) Library "diCrPKI.dll" alias for "RSA_DecodeMsg;ansi"
Function integer RSA_RawPrivate (Ref blob abData, integer nDataLen, string strPrivateKey,integer nOptions) Library "diCrPKI.dll" alias for "RSA_RawPrivate;ansi"
Function integer RSA_RawPublic (Ref blob abData, integer nDataLen, string strPublicKey,integer nOptions) Library "diCrPKI.dll" alias for "RSA_RawPublic;ansi"
Function integer CNV_B64StrFromBytes (ref string strB64, integer nB64StrLen,Ref blob abData,integer nDataLen) Library "diCrPKI.dll" alias for "CNV_B64StrFromBytes;ansi"
Function integer CNV_BytesFromB64Str (ref string strB64, integer nB64StrLen,Ref blob abData) Library "diCrPKI.dll" alias for "CNV_BytesFromB64Str;ansi"
Espero que te sirva