c# to php function

I have a c# function that i need to convert into PHP can anyone help me?

private static string GenerateToken(string apiKey, string salt)

{

var now = DateTime.Now.ToUniversalTime();

var passwordBytes = Encoding.UTF8.GetBytes(apiKey + new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0).ToFileTimeUtc());

var saltBytes = Encoding.UTF8.GetBytes(salt);

var hash = Hash(passwordBytes, saltBytes);

return JsonConvert.SerializeObject(hash);

}

Current Function Not working

function GenerateToken($apiKey, $salt){

$now = round(microtime(true) * 1000);

$passwordBytes = base64_encode($apiKey . $now );

$saltBytes = base64_encode($salt);

$hash = base64_encode(hash('sha256', $passwordBytes . hash('sha256', $saltBytes), true ));

return $hash;

}

Thanks 🙂

submitted by /u/acreativeshop
[link] [comments]

Leave a Reply