xp-framework /core/src/main/php/security/checksum/MD5.class.php

Language PHP Lines 48
MD5 Hash d4c2f674b285ae80b23252e52e1da339 Estimated Cost $260 (why?)
Repository git://github.com/xp-framework/xp-framework.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */
 
  uses('security.checksum.Checksum');
  
  /**
   * MD5 checksum
   *
   * @see      xp://security.checksum.Checksum
   * @see      php://md5
   * @purpose  Provide an API to check MD5 checksums
   */
  class MD5 extends Checksum {
  
    /**
     * Create a new checksum from a string
     *
     * @param   string str
     * @return  security.checksum.MD5
     */
    public static function fromString($str) {
      return new MD5(md5($str));
    }

    /**
     * Returns message digest
     *
     * @return  security.checksum.MessageDigestImpl
     */
    public static function digest() {
      return MessageDigest::newInstance('md5');
    }

    /**
     * Create a new checksum from a file object
     *
     * @param   io.File file
     * @return  security.checksum.MD5
     */
    public static function fromFile($file) {
      return new MD5(md5_file($file->uri));
    }
  }
?>
Back to Top