home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / xp_md5.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.0 KB  |  74 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * xp_md5.h: RSA MD5 algorithm
  21.  *
  22.  * For the most part this is RSA's public domain md5.h,
  23.  * with a couple of new utility functions for us.
  24.  *
  25.  * Ari Luotonen
  26.  */
  27.  
  28. #ifndef XP_MD5_H
  29. #define XP_MD5_H
  30.  
  31. #include "xp_core.h"
  32.  
  33. XP_BEGIN_PROTOS
  34. /*
  35.  * XP_Md5Binary(data, digest)
  36.  *    calculates the MD5 signature for 'data' of length 'len',
  37.  *    and places the 16-byte binary signature into 'digest' which must
  38.  *    be allocated by the caller.
  39.  *
  40.  */
  41. void XP_Md5Binary(char *data, int len, unsigned char digest[16]);
  42.  
  43.  
  44. /*
  45.  * XP_Md5PCPrintable(data, len)
  46.  *    returns a newly allocated string of given length, filled with
  47.  *    a printable version of the MD5 signature for 'data' that is
  48.  *    also a valid filename also on PC.
  49.  *
  50.  *    This maps only five bits to each char to make it work on the
  51.  *    braindead, case-insensitive-filesystem PC, aaaarrgh.
  52.  *
  53.  *    So for each 5 bytes it takes, it gives 8 printable bytes,
  54.  *    with bits taken from original data as follows:
  55.  *
  56.  *    [byte][bit]..[byte][bit]    byte=0..4, bit=1..8
  57.  *
  58.  *    [0][1]..[0][5]
  59.  *    [0][6]..[1][2]
  60.  *    [1][3]..[1][7]
  61.  *    [1][8]..[2][4]
  62.  *    [2][5]..[3][1]
  63.  *    [3][2]..[3][6]
  64.  *    [3][7]..[4][3]
  65.  *    [4][4]..[4][8]
  66.  *
  67.  */
  68. char *XP_Md5PCPrintable(char *data, int len);
  69.  
  70. XP_END_PROTOS
  71.  
  72. #endif /* ! XP_MD5_H */
  73.  
  74.