ID Chip Reader
util.h File Reference

Header file for utility functions. More...

Go to the source code of this file.

Macros

#define UTILS_UTIL_H_
 

Functions

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...
 

Detailed Description

Header file for utility functions.

Author
Khoa Nguyen

Macro Definition Documentation

◆ UTILS_UTIL_H_

#define UTILS_UTIL_H_

Function Documentation

◆ CharToInt()

int CharToInt ( const char  c)

Converts a character to an integer.

Parameters
cThe 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
yearPointer to an unsigned char array containing the year.
currentYearThe 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
dataPointer to an unsigned char array containing the data.
lengthLength 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
millisecondThe number of milliseconds to delay the program.

◆ ExpirationYearCalculate()

int ExpirationYearCalculate ( const int  birthYear,
const int  currentYear 
)

Calculates the expiration year of a document.

Parameters
birthYearThe birth year of the document holder.
currentYearThe current year.
Returns
The expiration year of the document.

◆ IntToChar()

char IntToChar ( const int  i)

Converts an integer to a character.

Parameters
iThe 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
dayThe day of the date.
monthThe 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
documentNumberPointer to an unsigned char array containing the document number.
birthDatePointer to an unsigned char array containing the birth date in YYMMDD format.
mrzInformationPointer to an unsigned char array where the MRZ information will be stored.
currentYearThe 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
byteArrayPointer to an unsigned char array that needs to be padded with zeros.
startPositionThe 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
bufferPointer to an unsigned char array where the generated nonce will be stored.
lenLength of the buffer, determines how many bytes of nonce will be generated.