我有一个python代码,但是我需要用PHP做同样的事情,我不能
我必须在php中执行校验和,但是我没有做到这一点,在python中代码工作正常,但是在php中我没有做到这一点
这是python中的代码:
import hashlib
import sys
endUserId = "User123" #insert internal user ID here
applicationKey = "123456789123456789123456789" #insert application key here
applicationId = "1234" #insert App ID here.
checkSum = hashlib.md5(endUserId + applicationId + applicationKey)
userId = endUserId + "-" + applicationId + "-" + checkSum.hexdigest()[:10]
print(userId)
在PHP中,我只能创建MD5并选择前10个字符,但这对我没有帮助,因为我需要python中获得的校验和
<?php
$endUserId = "User123" //insert internal user ID here
$applicationKey = "123456789123456789123456789"; //insert application key here
$applicationId = "1234" //insert App ID here.
$hash = substr(md5($endUserId.'-'.$applicationId.'-'.$applicationKey), 0, 10);
$user_id = $endUserId.'-'.$applicationId.'-'.$hash;
<?
如何在php中执行校验和(checksum),就像上面的python代码一样,并获得10个字符
你可以这样做,我不知道你想要的是前10个还是后10个,但下面的代码将帮助你 如果前10个字符
如果最后10个字符
确保使用if语句检查字符串的长度
相关问题 更多 >
编程相关推荐