Node:MD5, Next:, Previous:Intl, Up:GPC Units



MD5 Message Digests

The following listing contains the interface of the MD5 unit.

This unit provides functions to compute MD5 message digest of files or memory blocks, according to the definition of MD5 in RFC 1321 from April 1992.

{ Functions to compute MD5 message digest of files or memory blocks,
  according to the definition of MD5 in RFC 1321 from April 1992.

  IMPORTANT NOTE: This unit is distributed under the GNU GPL, NOT
  under the GNU LGPL under which most of the other GPC units are
  distributed. This means that you must distribute any code that
  uses this unit under the GPL as well, which means that you have to
  make the source code available whenever you distribute a binary of
  the code, and that you must allow recipients to modify the code
  and redistribute it under the GPL.

  Copyright (C) 1995, 1996, 2000-2003 Free Software Foundation, Inc.

  Based on the C code written by Ulrich Drepper
  <drepper@gnu.ai.mit.edu>, 1995 as part of the GNU C Library.

  This file is part of GNU Pascal.

  GNU Pascal is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2, or (at your
  option) any later version.

  GNU Pascal is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with GNU Pascal; see the file COPYING. If not, write to the
  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA. }

{$gnu-pascal,I-}
{$if __GPC_RELEASE__ < 20030303}
{$error This unit requires GPC release 20030303 or newer.}
{$endif}

unit MD5;

interface

uses GPC;

{ Representation of a MD5 value. It is always in little endian byte
  order and therefore portable. }
type
  Card8 = Cardinal attribute (Size = 8);
  TMD5 = array [1 .. 16] of Card8;

const
  MD5StrLength = 2 * High (TMD5);

{ Computes MD5 message digest for Length bytes in Buffer. }
procedure MD5Buffer (const Buffer; Length: SizeType; var MD5: TMD5);
  attribute (name = '_p_MD5Buffer');

{ Computes MD5 message digest for the contents of the file f. }
procedure MD5File (var f: File; var MD5: TMD5); attribute
  (iocritical, name = '_p_MD5File');

{ Initializes a MD5 value with zeros. }
procedure MD5Clear (var MD5: TMD5); attribute (name
  = '_p_MD5Clear');

{ Compares two MD5 values for equality. }
function MD5Compare (const Value1, Value2: TMD5): Boolean; attribute
  (name = '_p_MD5Compare');

{ Converts an MD5 value to a string. }
function MD5Str (const MD5: TMD5) = s: TString; attribute (name
  = '_p_MD5Str');

{ Converts a string to an MD5 value. Returns True if successful. }
function MD5Val (const s: String; var MD5: TMD5): Boolean; attribute
  (name = '_p_MD5Val');

{ Composes two MD5 values to a single one. }
function MD5Compose (const Value1, Value2: TMD5) = Dest: TMD5;
  attribute (name = '_p_MD5Compose');