Crates.io | emv_tlv_parser |
lib.rs | emv_tlv_parser |
version | 0.1.11 |
source | src |
created_at | 2023-11-29 12:55:44.290047 |
updated_at | 2024-02-19 08:57:58.344527 |
description | A library to Parse emv tlv messages |
homepage | |
repository | https://github.com/HosseinAssaran/TLV-Parser |
max_upload_size | |
id | 1053014 |
size | 32,890 |
This is a TLV (Tag-Length-Value) parser implemented in Rust and PHP. The parser can decode TLV-encoded data and represents each tag as a struct called Tag
. The Tag
struct has the following fields:
id
: Vector of bytes representing the tag identifier.length
: Length of the value field.value
: Vector of bytes representing the value.Additionally, the Tag
struct has a method is_constructed
to check if the tag is constructed.
.\tlv_parser_downloader.bat
php -S localhost:12345
localhost:12345
Important Note: As the PHP Web server uses a rust program to parse the message, you will need it. You can achieve this program by building release of the rust written program from the source or you can downlaod the executable file with tlv_parser_downloader as it mentioned above.
use emv_tlv_parser::parse_tlv;
let data_raw = "6F1A840E315041592E5359532E4444463031A5088801025F2D02656E";
match parse_tlv(data_raw.to_string()) {
Ok(tags) => tags.iter().for_each(|tag| println!("{}", tag)),
Err(e) => eprintln!("Error parsing TLV: {}", e)
}
To run the program, use the following command:
cargo run
To run the tests, use the following command:
cargo test