Skip to content

Instantly share code, notes, and snippets.

@tong
Last active October 3, 2015 13:58
Show Gist options
  • Select an option

  • Save tong/2464432 to your computer and use it in GitHub Desktop.

Select an option

Save tong/2464432 to your computer and use it in GitHub Desktop.
SASL-MD5 remote computation for XMPP clients
import jabber.sasl.MD5Calculator;
using Lambda;
/**
Simple, remote SASL-MD5 calculator for XMPP clients
*/
class Index {
static var passwords = {
tong : 'test'
};
static inline function print(t) php.Lib.print(t)
static function main() {
var params = php.Web.getParams();
var host = params.get( 'host' );
var servertype = params.get( 'servertype' );
var username = params.get( 'username' );
var realm = params.get( 'realm' );
var nonce = params.get( 'nonce' );
if( host == null || servertype == null || username == null || realm == null || nonce == null ) {
print(null);
return;
}
var pw = Reflect.field( passwords, username );
if( pw == null ) {
print(null);
return;
}
var hash : String = null;
try hash = MD5Calculator.run( host, servertype, username, realm, pw, nonce ) catch( e : Dynamic ) {
print(null);
return;
}
print( hash );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment