Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Reverse a hash function? (https://www.delphipraxis.net/156292-reverse-hash-function.html)

user 26. Nov 2010 15:25

Delphi-Version: 2007

Reverse a hash function?
 
Does it possible to decrypt the hash from this function?

Delphi-Quellcode:
type TAdlerBytes = array[1..MAXINT] of Byte;
     TAdlerArray = array[0..16] of Integer;
     PAdlerBytes = ^TAdlerBytes;

implementation

{$R *.dfm}
function FNV32(PAB:PAdlerBytes;ACount:Integer):DWORD;
var i,APrime:DWORD;
begin
  APrime:= 16777619;
  Result:=2166136261;
  for i:=1 to ACount do
  begin
    Result:=Result*APrime;
    Result:=Result xor PAB^[i];
  end;
  //FNV stands for Fowler-Noll-Vo.
  //Read up on FNV at http://www.isthe.com/chongo/tech/comp/fnv
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i:dword;
s:string;
begin
s:='aaabbbffggfd';
i:=fnv32(PAdlerBytes(s),length(s));
OutputDebugString(pchar(inttostr(i)));
end;

JasonDX 26. Nov 2010 16:04

AW: Reverse a hash function?
 
Zitat:

Zitat von user (Beitrag 1064297)
Does it possible to decrypt the hash from this function?

Well, you map a string of arbitrary length to a finite field, so you do have some collisions. It therefore is not always possible to 'decrypt' the hash (in the sense of getting s from h(s), h being the hash function), but you can always find a string s' that hashes to the same value, hence h(s) = h(s'). The next question would then propably be how long it takes to find such string.

greetz
Mike

mkinzler 26. Nov 2010 16:19

AW: Reverse a hash function?
 
Not being reversible is the nature of a hash function

himitsu 26. Nov 2010 16:43

AW: Reverse a hash function?
 
hash = one-way encryption

This can not be reversed.


[edit]
Wo kommen denn "plötzlich" die vielen Antworten her?
(grad eben waren die noch nicht da)

user 26. Nov 2010 17:44

AW: Reverse a hash function?
 
Hmm.. I think reversing the function is bad idea. I am on panic and I have wrong concept in my program. Sorry, I'm still learning. Thanks.


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz