Cita:
Empezado por nincillo
El "problema" es que en mi caso, la programación "importante" la tengo con librerías que en el 10.3 no me compilan. Por eso mi interés en poder hacerlo con el D2007.
Por otro lado, el visto el post que pusiste indicando un método de hacer el hash, pero por lo que veo tampoco es compatible ni con el 2007, ni con el XE2. Tendré que mirar que al menos lo sea con el 10.3.
|
Compañero yo puse un codigo para calcular el hash de RegistroFacturacion metido en una librería de enlace dinámico (dll)
No se si está en la página 37 o 38 y me funciona está creada con delphi 10.2 y la llamo desde delphi 7 me crea el hash 256 que he comprobado en algunas web's y está perfecto.
Aqui está el código de la librería:
Código:
library CalcHashSha256;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
System.SysUtils,
system.hash,
System.Classes,
system.netEncoding;
{$R *.res}
function CalculaStrHashSHA256(Str: WideString; Base64: Boolean): WideString;
function Base64Encode(Str: WideString): WideString;
var
encoder: TBase64Encoding;
begin
encoder:=TBase64Encoding.Create();
result:=encoder.Encode(str);
encoder.Free;
end;
var
HashSHA: THashSHA2;
begin
HashSHA := THashSHA2.Create;
HashSHA.GetHashString(Str);
result := HashSHA.GetHashString(Str,SHA256);
if Base64 = True then result := Base64Encode(Str);
end;
Exports CalculaStrHashSha256;
begin
end.
Ejemplo de llamada:
Código:
Huella := CalculaStrHashSHA256(ContenidoNodoRegistroFacturacion, checkBox1.Checked)