Buenas noches con todos, si me pudieran ayudar a como obtener los hashes de un archivo.

Obtener todos los hashes (md5, sha1, sha256, sha384, sha215, CRC, etc...)
#1
Escrito 08 junio 2015 - 01:25
#2
Escrito 08 junio 2015 - 02:00
Buenas noches con todos, si me pudieran ayudar a como obtener los hashes de un archivo.
Porqué necesitas todos? Con sha256 y md5 suele ser mas que suficiente en la mayoría de los casos.
En mi web http://delphi.jmrds.com encontraras las librerías SeCrypt y que incluyen tanto md5 como sha256. Para el resto de algoritmos no te puedo ayudar.
Saludos
#3
Escrito 08 junio 2015 - 11:28
Muchas gracias por la respuesta, lo que sucede es que deseo hacer un software completo de hashes e información de un archivo, el md5 y el sha1 lo saco así:
.
Pero los demás hashes (sha256, sha384, sha215, CRC, etc...) no logro sacarlos, por eso acudo a su ayuda.
#4
Escrito 19 junio 2015 - 10:47
Buenas amigos de momento he logrado un pequeño avance mediante el componente "DCPcrypt" que lo baje de acá:
http://www.cityinthe...ource/dcpcrypt/
del mismo baje un demo creo que se llamaba "DCPcrypt v2 for Delphi 2009/2010"
Modificandolo logré un pequeño avance adjunto las fuentes:
unit Unit1; {$mode objfpc}{$H+} interface uses windows, messages, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, CheckLst, Buttons, DCPtiger, DCPsha512, DCPsha256, DCPsha1, DCPripemd160, DCPripemd128, DCPmd5, DCPmd4, DCPcrypt2, DCPhaval; type { TForm1 } TForm1 = class(TForm) btnHash: TButton; grpOutput: TGroupBox; DCP_haval1: TDCP_haval; DCP_md4_1: TDCP_md4; DCP_md5_1: TDCP_md5; DCP_ripemd128_1: TDCP_ripemd128; DCP_ripemd160_1: TDCP_ripemd160; DCP_sha1_1: TDCP_sha1; DCP_sha256_1: TDCP_sha256; DCP_sha384_1: TDCP_sha384; DCP_sha512_1: TDCP_sha512; DCP_tiger1: TDCP_tiger; boxInputFile: TEdit; grpHashes: TGroupBox; btnBrowseFiles: TSpeedButton; dlgOpen: TOpenDialog; lstHashes: TCheckListBox; txtOutput: TMemo; procedure btnBrowseFilesClick(Sender: TObject); procedure btnHashClick(Sender: TObject); procedure FormCreate(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); var i: integer; begin {ClientHeight := 416; ClientWidth := 408;} MessageDlg('This is a file hashing demo using the DCPcrypt component set.'+#13+'For more information see http://www.cityinthesky.co.uk/cryptography.html',mtInformation,[mbOK],0); // find all the hash algorithms on the form for i := 0 to ComponentCount - 1 do begin if Components[i] is TDCP_hash then begin end; end; end; procedure TForm1.btnHashClick(Sender: TObject); var i, j, read: integer; s: string; strmInput: TFileStream; begin txtOutput.Clear; if not FileExists(boxInputFile.Text) then begin MessageDlg('File does not exist',mtInformation,[mbOK],0); Exit; end; Hashes := nil; // make a list of all the hash algorithms to use begin if lstHashes.Checked[i] then begin // yes I know this is inefficient but it's also easy ;-) SetLength(Hashes,Length(Hashes) + 1); Hashes[Length(Hashes) - 1] := TDCP_hash(lstHashes.Items.Objects[i]); TDCP_hash(lstHashes.Items.Objects[i]).Init; end; end; strmInput := nil; try strmInput := TFileStream.Create(boxInputFile.Text,fmOpenRead); repeat // read into the buffer // hash the buffer with each of the selected hashes for i := 0 to Length(Hashes) - 1 do Hashes[i].Update(buffer,read); strmInput.Free; // iterate through the selected hashes for i := 0 to Length(Hashes) - 1 do begin SetLength(HashDigest,Hashes[i].HashSize div 8); Hashes[i].Final(HashDigest[0]); // get the output s := ''; for j := 0 to Length(HashDigest) - 1 do // convert it into a hex string s := s + IntToHex(HashDigest[j],2); txtOutput.Lines.Add(Hashes[i].Algorithm + ': ' + s); end; except strmInput.Free; MessageDlg('An error occurred while reading the file',mtError,[mbOK],0); end; end; procedure TForm1.btnBrowseFilesClick(Sender: TObject); begin if dlgOpen.Execute then boxInputFile.Text := dlgOpen.FileName; end; end.
Espero me puedan ayudar a mejorarlo o usar alternativas, gracias de antemano.