Permalink
Browse files

Add generic PHP code for decryption/parsing

In general, you're better off looking at the mediawiki plugin which
is a bit more complete..
  • Loading branch information...
1 parent f1ee1f4 commit f940801e3f58bd8f364117eb2ee1fbbd0a9733c4 @mhagander committed Jun 3, 2012
Showing with 33 additions and 0 deletions.
  1. +33 −0 tools/communityauth/sample/php/generic_php.php
@@ -0,0 +1,33 @@
+#!/usr/bin/env php
+<?php
+if ($argc != 4) {
+ print "Usage: generic_php.php <iv> <data>\n\n";
+ exit(1);
+}
+
+$key = $argv[1];
+$iv = $argv[2];
+$d = $argv[3];
+
+$key = base64_decode(strtr($key, '-_', '+/'), true);
+$iv = base64_decode(strtr($iv, '-_', '+/'), true);
+$d = base64_decode(strtr($d, '-_', '+/'), true);
+
+$td = mcrypt_module_open("rijndael-128", "", "cbc", "");
+mcrypt_generic_init($td, $key, $iv);
+$decrypted = mdecrypt_generic($td, $d);
+mcrypt_generic_deinit($td);
+mcrypt_module_close($td);
+
+parse_str($decrypted, $data);
+
+if ($data['t'] < time() - 10) {
+ print "*** Authentication timestamp too old ***\n";
+}
+
+print "User: " . $data['u'] . "\n";
+print "Email: " . $data['e'] . "\n";
+print "First: " . $data['f'] . "\n";
+print "Last: " . $data['l'] . "\n";
+print "\n";
+?>

0 comments on commit f940801

Please sign in to comment.