mirror of https://github.com/captn3m0/epicqr.git
Adds PHP code, autogenerated from Haxe (somewhat)
We do some wizardry to avoid too much code.
This commit is contained in:
parent
2bbaf6120e
commit
28d3191077
|
@ -2,4 +2,11 @@ haxe-build.zip
|
|||
build/
|
||||
|
||||
*.jar
|
||||
*.class
|
||||
*.class
|
||||
# These are generated PHP code for Haxe
|
||||
# but since our PHP code is so simple, we
|
||||
# don't need any of these
|
||||
src/php
|
||||
src/Array_hx.php
|
||||
src/Std.php
|
||||
src/haxe
|
|
@ -5,4 +5,9 @@ zip -r haxe-build.zip src LICENSE *.md *.json *.hxml
|
|||
|
||||
# Java
|
||||
javac -cp src src/eci/*.java -d build/
|
||||
jar -cf epicqr-release.jar build/*
|
||||
jar -cf epicqr-release.jar build/*
|
||||
|
||||
# PHP
|
||||
haxe php.hxml
|
||||
sed -i '/^use/d' src/eci/*.php
|
||||
sed -i '/^Boot::/d' src/eci/*.php
|
|
@ -0,0 +1,10 @@
|
|||
-cp src
|
||||
-w -WDeprecatedEnumAbstract
|
||||
-php .
|
||||
--dce full
|
||||
--macro keep('eci.EpicQR')
|
||||
--macro keep('eci.Result')
|
||||
-D analyzer_optimize
|
||||
-D real-position
|
||||
-D php-lib=src
|
||||
eci.EpicQR
|
|
@ -1,11 +1,17 @@
|
|||
package eci;
|
||||
|
||||
#if php
|
||||
import php.Global;
|
||||
import php.Lib;
|
||||
#elseif nodejs
|
||||
import js.node.Crypto;
|
||||
import js.node.Buffer;
|
||||
#else
|
||||
import haxe.io.Bytes;
|
||||
import haxe.crypto.Base64;
|
||||
import haxe.crypto.mode.CBC;
|
||||
import haxe.Json;
|
||||
import js.node.Crypto;
|
||||
import js.node.Buffer;
|
||||
#end
|
||||
|
||||
@:expose
|
||||
class EpicQR{
|
||||
|
@ -15,7 +21,9 @@ class EpicQR{
|
|||
|
||||
public static inline var IV:String = "H76$suq23_po(8sD";
|
||||
public static inline var KEY:String = "X_4k$uq23FSwI.qT"; // KEY_PREFIX + SALT
|
||||
#if nodejs
|
||||
private static inline var UTF8:String = "utf8";
|
||||
#end
|
||||
|
||||
static function decode(input : String){
|
||||
#if nodejs
|
||||
|
@ -30,6 +38,11 @@ class EpicQR{
|
|||
decrypted = decrypted.slice(0, decrypted.length - paddingLength);
|
||||
|
||||
var _d = haxe.Json.parse(decrypted.toString(UTF8));
|
||||
#elseif php
|
||||
var ct = Global.base64_decode(input);
|
||||
var jsonString = Global.call_user_func('openssl_decrypt', ct, 'aes-128-cbc', KEY, 1, IV);
|
||||
var _d = Global.json_decode(jsonString);
|
||||
|
||||
#else
|
||||
var cipherText:Bytes = Base64.decode(input);
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Generated by Haxe 4.3.3
|
||||
*/
|
||||
|
||||
namespace eci;
|
||||
|
||||
|
||||
class EpicQR {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const IV = "H76\$suq23_po(8sD";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const KEY = "X_4k\$uq23FSwI.qT";
|
||||
|
||||
/**
|
||||
* @param string $input
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public static function decode ($input) {
|
||||
$ct = \base64_decode($input);
|
||||
$jsonString = \call_user_func("openssl_decrypt", $ct, "aes-128-cbc", "X_4k\$uq23FSwI.qT", 1, "H76\$suq23_po(8sD");
|
||||
$_d = \json_decode($jsonString);
|
||||
return new Result($_d->epic_no, $_d->unique_generated_id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Generated by Haxe 4.3.3
|
||||
*/
|
||||
|
||||
namespace eci;
|
||||
|
||||
|
||||
class Result {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $epic;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @param string $epic
|
||||
* @param int $id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct ($epic, $id) {
|
||||
$this->epic = $epic;
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue