Forum QuickConnect Code example for AS3 auth-hash

Discussion and help relating to PlayerIO's QuickConnect feature, including Facebook Connect and Kongregate Connect.

Code example for AS3 auth-hash

Postby cjcenizal » October 20th, 2011, 12:12 am

I noticed this page (http://playerio.com/documentation/connections) missing an example on how to create an auth-hash in AS3, so I wrote one up:

Code: Select all
private function makeHash( mUserId:String, mSecret:String ):String {
   var now:Date = new Date();
   var unixTime:String = Math.round( now.time * .001 ).toString();
   var message:String = unixTime + ":" + mUserId;
   return unixTime + ":" + HMAC.hash( mSecret, message, SHA1 );
}


HMAC and SHA1 are classes provided as part of as3corelib (https://github.com/mikechambers/as3corelib). You'll just need to import them like so:

Code: Select all
import com.adobe.crypto.SHA1;
import com.adobe.crypto.HMAC;
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Code example for AS3 auth-hash

Postby FulaFisken » October 20th, 2011, 1:25 am

Thanks!
Fula Fisken
website blog twitter
Play Game
Astroflux
User avatar
FulaFisken
Paid Member
 
Posts: 139
Joined: March 2nd, 2011, 10:15 am

Re: Code example for AS3 auth-hash

Postby Oliver » November 7th, 2011, 3:56 pm

Thanks for the code example.

I'm hesitant to add it to the list of example code snippets, since I'm worried that it will lead to people embedding their secret key into their flash file which is not very secure.

Thoughts?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Code example for AS3 auth-hash

Postby Henrik » November 7th, 2011, 3:59 pm

I'd be hesitant to add it to the documentation since it uses a 3rd party library. No idea how widespread that one is, though.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm


Return to QuickConnect



cron