Files
selima-perl/lib/php/monica/md5.inc.php
2026-03-10 21:31:43 +08:00

25 lines
592 B
PHP

<?php
// File name: md5.inc.php
// Description: PHP subroutine to calculate MD5 digests
// Date: 2004-07-04
// Author: imacat <imacat@pristine.com.tw>
// Copyright: Copyright (C) 2004-2007 Pristine Communications
// md5_raw: Return the raw MD5 binary digest
function md5_raw($content)
{
$md5hex = md5($content);
for ($i = 0, $md5 = ""; $i < strlen($md5hex); $i += 2) {
$md5 .= chr(hexdec(substr($md5hex, $i, 2)));
}
return $md5;
}
// md5_base64: Return the Base64-encoded MD5 digest
function md5_base64($content)
{
return base64_encode(md5_raw($content));
}
?>