setDrmKey static method

void setDrmKey(
  1. MobiData data,
  2. String? pid
)

Implementation

static void setDrmKey(MobiData data, String? pid) {
  if (pid != null) {
    if (pid.length != pidSize) {
      throw MobiInvalidPidException();
    }
    if (!verifyDrmKey(pid)) {
      throw MobiInvalidPidException();
    }
    if (!isEncrypted(data)) {
      addCookie(data, pid, 0, mobiNotSet);
      return;
    }
  }
  if (data.record0header?.encryptionType == mobiEncryptionV1) {
    // MOBI encryption V1 doesn't need PID
    pid = null;
  }
  var key = getDrmKey(pid, data);
  initDrmKey(data, key);
  if (data.record0header!.encryptionType! > 1) {
    addCookie(data, pid, 0, mobiNotSet);
  }
}