Home > Backend Development > PHP Tutorial > How to convert such a section of python into SegmentFault

How to convert such a section of python into SegmentFault

WBOY
Release: 2016-09-09 08:28:02
Original
1150 people have browsed it

<code>def getVMS(tvid, vid):
    t = int(time.time() * 1000)
    key = 'd5fb4bd9d50c4be6948c97edd7254b0e'
    sc = hashlib.new('md5', bytes(str(t) + key  + vid, 'utf-8')).hexdigest()
    return sc</code>
Copy after login
Copy after login

Reply content:

<code>def getVMS(tvid, vid):
    t = int(time.time() * 1000)
    key = 'd5fb4bd9d50c4be6948c97edd7254b0e'
    sc = hashlib.new('md5', bytes(str(t) + key  + vid, 'utf-8')).hexdigest()
    return sc</code>
Copy after login
Copy after login

Completely literal translation

<code class="php">function getVMS($tvid, $vid) {
    $t   = floor(microtime(1) * 1000);
    $key = 'd5fb4bd9d50c4be6948c97edd7254b0e';
    $sc  = md5($t . $key . $vid);
    return $sc;
}</code>
Copy after login
  • Use floor instead of intval because the time milliseconds exceed the maximum range of an integer

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template