Ver Mensaje Individual
  #1026  
Antiguo 03-01-2024
Avatar de ramherfer
ramherfer ramherfer is offline
Miembro
 
Registrado: may 2013
Ubicación: Valencia
Posts: 51
Reputación: 11
ramherfer Va por buen camino
Cita:
Empezado por nincillo Ver Mensaje
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)
__________________
Se humilde para admitir tus errores, inteligente para aprender de ellos y maduro para corregirlos.

Última edición por ramherfer fecha: 03-01-2024 a las 20:46:26.
Responder Con Cita