~ubuntu-branches/ubuntu/gutsy/php5/gutsy

« back to all changes in this revision

Viewing changes to ext/standard/md5.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-06-11 20:32:54 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070611203254-b4k8nggrm5vxul1j
Tags: 5.2.3-1ubuntu1
* Merge from debian unstable, remaining changes:
 - debian/changelog: Add some missing CVEs.
 - debian/control: DebianMaintainerField
 - debian/control, debian/rules: Disable a few build dependencies and
   accompanying binary packages which we do not want to support in main:
   + firebird2-dev/php5-interbase (we have a separate php-interbase source)
   + libc-client-dev/php5-imap (we have a separate php-imap source)
   + libmcrypt-dev/php5-mcrypt (separate php-mcrypt source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
   +----------------------------------------------------------------------+
17
17
*/
18
18
 
19
 
/* $Id: md5.c,v 1.39.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */
 
19
/* $Id: md5.c,v 1.39.2.1.2.4 2007/05/27 15:29:38 nlopess Exp $ */
20
20
 
21
21
/* 
22
22
 * md5.c - Copyright 1997 Lachlan Roche 
28
28
 
29
29
PHPAPI void make_digest(char *md5str, unsigned char *digest)
30
30
{
 
31
        make_digest_ex(md5str, digest, 16);
 
32
}
 
33
 
 
34
PHPAPI void make_digest_ex(char *md5str, unsigned char *digest, int len)
 
35
{
 
36
        static const char hexits[17] = "0123456789abcdef";
31
37
        int i;
32
38
 
33
 
        for (i = 0; i < 16; i++) {
34
 
                sprintf(md5str, "%02x", digest[i]);
35
 
                md5str += 2;
 
39
        for (i = 0; i < len; i++) {
 
40
                md5str[i * 2]       = hexits[digest[i] >> 4];
 
41
                md5str[(i * 2) + 1] = hexits[digest[i] &  0x0F];
36
42
        }
37
 
 
38
 
        *md5str = '\0';
 
43
        md5str[len * 2] = '\0';
39
44
}
40
45
 
41
46
/* {{{ proto string md5(string str, [ bool raw_output])
60
65
        if (raw_output) {
61
66
                RETURN_STRINGL(digest, 16, 1);
62
67
        } else {
63
 
                make_digest(md5str, digest);
 
68
                make_digest_ex(md5str, digest, 16);
64
69
                RETVAL_STRING(md5str, 1);
65
70
        }
66
71
 
107
112
        if (raw_output) {
108
113
                RETURN_STRINGL(digest, 16, 1);
109
114
        } else {
110
 
                make_digest(md5str, digest);
 
115
                make_digest_ex(md5str, digest, 16);
111
116
                RETVAL_STRING(md5str, 1);
112
117
        }
113
118
}