checkLicenseWithCard static method

Uint8List checkLicenseWithCard(
  1. String? licensePath
)

Checks the license by using a card-based verification process. It takes the path to the license file and outputs a challenge response for further verification.

param licensePath The file path to the license that needs to be checked. return An array to hold the challenge response generated by the host. throws FaceException An error has occurred during Face Library execution.

Implementation

static Uint8List checkLicenseWithCard(String? licensePath) {
  Pointer<Char>? pLicensePath = licensePath?.toNativeUtf8().cast<Char>();
  Pointer<UnsignedChar> pChallengeR1 = calloc.allocate(16);
  Pointer<Int> pChallengeR1Size = calloc.allocate(1);
  pChallengeR1Size[0] = 16;
  try {
    var err = faceSDK.id3FaceLicense_CheckLicenseWithCard(pLicensePath ?? nullptr, pChallengeR1, pChallengeR1Size);
    if (err == FaceError.insufficientBuffer.value) {
      calloc.free(pChallengeR1);
      pChallengeR1 = calloc.allocate(pChallengeR1Size.value);
      err = faceSDK.id3FaceLicense_CheckLicenseWithCard(pLicensePath ?? nullptr, pChallengeR1, pChallengeR1Size);
    }
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vChallengeR1 = Uint8List.fromList(pChallengeR1.cast<Uint8>().asTypedList(pChallengeR1Size.value));
    return vChallengeR1;
  } finally {
    if (pLicensePath != null) {
      calloc.free(pLicensePath);
    }
    calloc.free(pChallengeR1);
    calloc.free(pChallengeR1Size);
  }
}