Convert 2 Actionscript Functions To Php

I want these 2 AS3 function converted into PHP. It must have exactly the same results (same signature and nonce). The signature function uses AS3Crypto with SHA1.

for information:
param1 = the data to encrypt
param2 = secret key
param3 = token key

public function signature(param1:String, param2:String, param3:String = “”) : String
{
var token:* = param2 + “&” + param3;
var _loc_5:* = Crypto.getHMAC(“sha1”);
var _loc_6:* = Hex.toArray(Hex.fromString(token));
var _loc_7:* = Hex.toArray(Hex.fromString(param1));
var _loc_8:* = _loc_5.compute(_loc_6, _loc_7);
var _loc_9:* = Base64.encodeByteArray(_loc_8);
return Base64.encodeByteArray(_loc_8);
}

public static function OAuthNonce() : String
{
var _loc_1:* = new Date();
var _loc_2:* = new Date(_loc_1.getUTCFullYear() + 1970, _loc_1.getUTCMonth(), _loc_1.getUTCDate(), _loc_1.getUTCHours(), _loc_1.getUTCMinutes(), _loc_1.getUTCSeconds(), _loc_1.getUTCMilliseconds());
return (_loc_2.getTime() * 10000).toString();
}

Leave a Reply

Your email address will not be published. Required fields are marked *