🏡 index : github.com/captn3m0/epicqr.git

author Nemo <me@captnemo.in> 2024-01-05 21:52:42.0 +05:30:00
committer Nemo <me@captnemo.in> 2024-01-05 21:52:42.0 +05:30:00
commit
4d5012ce3bf35a69a6e1d31fc175479207dcfb0e [patch]
tree
460ed50b08326a39c2b4fa3f6d2d48b7f14425b3
download
0.9.1.tar.gz

initial commit



Diff

 .gitignore       |  1 +
 LICENSE          |  8 ++++++++
 README.md        |  7 +++++++
 extraParams.hxml |  1 +
 haxelib.json     | 14 ++++++++++++++
 release.sh       |  4 ++++
 src/EpicQR.hx    | 37 +++++++++++++++++++++++++++++++++++++
 7 files changed, 72 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dc4f76f 100644
--- /dev/null
+++ a/.gitignore
@@ -1,0 +1,1 @@
library.zip
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0887c41 100644
--- /dev/null
+++ a/LICENSE
@@ -1,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2023 Abhay Rana

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d196b71 100644
--- /dev/null
+++ a/README.md
@@ -1,0 +1,7 @@
# EPIC QR Decoder

Haxe library to decode a QR code on a modern EPIC Card.

## LICENSE

Licensed under MIT. See `LICENCE` file for more details.
diff --git a/extraParams.hxml b/extraParams.hxml
new file mode 100644
index 0000000..f953def 100644
--- /dev/null
+++ a/extraParams.hxml
@@ -1,0 +1,1 @@
-l crypto
diff --git a/haxelib.json b/haxelib.json
new file mode 100644
index 0000000..5e752c4 100644
--- /dev/null
+++ a/haxelib.json
@@ -1,0 +1,14 @@
{
  "name": "epicqr",
  "url" : "https://github.com/captn3m0/epicqr",
  "license": "MIT",
  "tags": ["qr", "voter-id"],
  "description": "Scan a EPIC QR code in an Indian Voter ID",
  "version": "0.9.1",
  "classPath": "src/",
  "releasenote": "Initial release",
  "contributors": ["captn3m0"],
  "dependencies": {
    "crypto": "1.0.4"
  }

}
diff --git a/release.sh b/release.sh
new file mode 100755
index 0000000..592f761 100755
--- /dev/null
+++ a/release.sh
@@ -1,0 +1,4 @@
#!/bin/sh
rm -f library.zip
zip -r library.zip src LICENSE *.md *.json *.hxml
haxelib submit library.zip $(pass show Dev/lib.haxe.org) --always
diff --git a/src/EpicQR.hx b/src/EpicQR.hx
new file mode 100644
index 0000000..b9eda41 100644
--- /dev/null
+++ a/src/EpicQR.hx
@@ -1,0 +1,37 @@
import haxe.crypto.Aes;
import haxe.io.Bytes;
import haxe.crypto.mode.Mode;
import haxe.crypto.padding.Padding;
import haxe.crypto.Base64;
import haxe.Json;

class Result {
    public var epic:String;
    public var id:String;

    public function new(epic: String, id: String) {
        this.epic  = epic;
        this.id = id;
    }
}

class EpicQR{
    // public static inline var KEY_SEED:String  = "tHzHtCcDd3V6p_9dOnse|_SX_4k$uq23.qT.L.(MgyJ7UH4n921J6UlKeck_S0Jl2znUY8CiMKyklWf2";
    // public static inline var KEY_PREFIX:String = "X_4k$uq23";
    // public static inline var SALT:String  = "FSwI.qT";

    public static inline var IV:String  = "H76$suq23_po(8sD";
    public static inline var KEY:String = "X_4k$uq23FSwI.qT"; // KEY+SALT

    static function decode(input:String){
        var cipherText:Bytes = Base64.decode(input);
        
        var aes : Aes = new Aes();
        var key = Bytes.ofString(KEY);
        var iv = Bytes.ofString(IV);
        aes.init(key,iv);
        var jsonString = aes.decrypt(Mode.CBC,cipherText,Padding.PKCS7).toString();
        var _d = Json.parse(jsonString);
        return new Result(_d.epic_no, _d.unique_generated_id);
    }
}