initial commit

This commit is contained in:
Nemo 2024-01-05 21:52:42 +05:30
commit 4d5012ce3b
7 changed files with 72 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
library.zip

8
LICENSE Normal file
View File

@ -0,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.

7
README.md Normal file
View File

@ -0,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.

1
extraParams.hxml Normal file
View File

@ -0,0 +1 @@
-l crypto

14
haxelib.json Normal file
View File

@ -0,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"
}
}

4
release.sh Executable file
View File

@ -0,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

37
src/EpicQR.hx Normal file
View File

@ -0,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);
}
}