Header file for utility functions.
More...
Go to the source code of this file.
|
void | Delay (int millisecond) |
| Delays the execution of the program for a specified number of milliseconds. More...
|
|
void | RandomNonceGenerate (unsigned char *buffer, int len) |
| Generates a random nonce and stores it in the provided buffer. More...
|
|
void | PadByteArray (unsigned char *byteArray, int startPosition) |
| Pads a byte array with zeros from a specified starting position to the end. More...
|
|
int | CharToInt (const char c) |
| Converts a character to an integer. More...
|
|
char | IntToChar (const int i) |
| Converts an integer to a character. More...
|
|
int | CheckDigitCalculate (const unsigned char *data, int length) |
| Calculates the check digit of a string of data. More...
|
|
int | ExpirationYearCalculate (const int birthYear, const int currentYear) |
| Calculates the expiration year of a document. More...
|
|
int | CharToYear (const unsigned char year[2], const int currentYear) |
| Converts a string of 2 characters to an integer representing a year. More...
|
|
int | IsValidDate (int day, int month) |
| Checks if a date is valid. More...
|
|
void | MrzInformationGenerate (const unsigned char documentNumber[9], const unsigned char birthDate[4], unsigned char mrzInformation[24], int currentYear) |
| Generates the MRZ information of a document. More...
|
|
Header file for utility functions.
- Author
- Khoa Nguyen
◆ UTILS_UTIL_H_
◆ CharToInt()
int CharToInt |
( |
const char |
c | ) |
|
Converts a character to an integer.
- Parameters
-
c | The character to be converted. |
- Returns
- The integer value of the character.
◆ CharToYear()
int CharToYear |
( |
const unsigned char |
year[2], |
|
|
const int |
currentYear |
|
) |
| |
Converts a string of 2 characters to an integer representing a year.
- Parameters
-
year | Pointer to an unsigned char array containing the year. |
currentYear | The current year. |
- Returns
- The year represented by the string.
◆ CheckDigitCalculate()
int CheckDigitCalculate |
( |
const unsigned char * |
data, |
|
|
int |
length |
|
) |
| |
Calculates the check digit of a string of data.
- Parameters
-
data | Pointer to an unsigned char array containing the data. |
length | Length of the data. |
- Returns
- The check digit of the data.
◆ Delay()
void Delay |
( |
int |
millisecond | ) |
|
Delays the execution of the program for a specified number of milliseconds.
- Parameters
-
millisecond | The number of milliseconds to delay the program. |
◆ ExpirationYearCalculate()
int ExpirationYearCalculate |
( |
const int |
birthYear, |
|
|
const int |
currentYear |
|
) |
| |
Calculates the expiration year of a document.
- Parameters
-
birthYear | The birth year of the document holder. |
currentYear | The current year. |
- Returns
- The expiration year of the document.
◆ IntToChar()
char IntToChar |
( |
const int |
i | ) |
|
Converts an integer to a character.
- Parameters
-
i | The integer to be converted. |
- Returns
- The character value of the integer.
◆ IsValidDate()
int IsValidDate |
( |
int |
day, |
|
|
int |
month |
|
) |
| |
Checks if a date is valid.
- Parameters
-
day | The day of the date. |
month | The month of the date. |
- Returns
- 1 if the date is valid, 0 otherwise.
◆ MrzInformationGenerate()
void MrzInformationGenerate |
( |
const unsigned char |
documentNumber[9], |
|
|
const unsigned char |
birthDate[4], |
|
|
unsigned char |
mrzInformation[24], |
|
|
int |
currentYear |
|
) |
| |
Generates the MRZ information of a document.
- Parameters
-
documentNumber | Pointer to an unsigned char array containing the document number. |
birthDate | Pointer to an unsigned char array containing the birth date in YYMMDD format. |
mrzInformation | Pointer to an unsigned char array where the MRZ information will be stored. |
currentYear | The current year. |
◆ PadByteArray()
void PadByteArray |
( |
unsigned char * |
byteArray, |
|
|
int |
startPosition |
|
) |
| |
Pads a byte array with zeros from a specified starting position to the end.
- Parameters
-
byteArray | Pointer to an unsigned char array that needs to be padded with zeros. |
startPosition | The position in the byteArray from which padding should start. |
◆ RandomNonceGenerate()
void RandomNonceGenerate |
( |
unsigned char * |
buffer, |
|
|
int |
len |
|
) |
| |
Generates a random nonce and stores it in the provided buffer.
- Parameters
-
buffer | Pointer to an unsigned char array where the generated nonce will be stored. |
len | Length of the buffer, determines how many bytes of nonce will be generated. |