PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/core/src/main/php/security/checksum/MD5.class.php

http://github.com/xp-framework/xp-framework
PHP | 47 lines | 14 code | 5 blank | 28 comment | 0 complexity | d4c2f674b285ae80b23252e52e1da339 MD5 | raw file
 1<?php
 2/* This class is part of the XP framework
 3 *
 4 * $Id$ 
 5 */
 6 
 7  uses('security.checksum.Checksum');
 8  
 9  /**
10   * MD5 checksum
11   *
12   * @see      xp://security.checksum.Checksum
13   * @see      php://md5
14   * @purpose  Provide an API to check MD5 checksums
15   */
16  class MD5 extends Checksum {
17  
18    /**
19     * Create a new checksum from a string
20     *
21     * @param   string str
22     * @return  security.checksum.MD5
23     */
24    public static function fromString($str) {
25      return new MD5(md5($str));
26    }
27
28    /**
29     * Returns message digest
30     *
31     * @return  security.checksum.MessageDigestImpl
32     */
33    public static function digest() {
34      return MessageDigest::newInstance('md5');
35    }
36
37    /**
38     * Create a new checksum from a file object
39     *
40     * @param   io.File file
41     * @return  security.checksum.MD5
42     */
43    public static function fromFile($file) {
44      return new MD5(md5_file($file->uri));
45    }
46  }
47?>