computeSha256 method

String computeSha256()

Computes the SHA-256 of the external resource's data.

return A string that contains the SHA-256. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

String computeSha256() {
  Pointer<Char> pResult = nullptr;
  Pointer<Int> pResultSize = calloc.allocate(1);
  pResultSize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealResourceCallbackArgs_ComputeSha256(_pHandle.value, pResult, pResultSize);
    if (err == BiosealError.insufficientBuffer.value) {
      pResult = calloc.allocate(pResultSize.value);
      err = biosealSDK.id3BiosealResourceCallbackArgs_ComputeSha256(_pHandle.value, pResult, pResultSize);
      if (err != BiosealError.success.value) {
        throw BiosealException(err);
      }
    }
    final vResult = utf8.decode(Uint8List.fromList(pResult.cast<Uint8>().asTypedList(pResultSize.value)));
    return vResult;
  } finally {
    calloc.free(pResult);
    calloc.free(pResultSize);
  }
}