calcPaddedLen function

int calcPaddedLen(
  1. int unpaddedLen
)

Implementation

int calcPaddedLen(int unpaddedLen) {
  int nextPower = 1 << ((unpaddedLen - 1).bitLength);
  int chunk = nextPower <= 256 ? 32 : nextPower ~/ 8;
  if (unpaddedLen <= 32) {
    return 32;
  } else {
    return chunk * ((unpaddedLen - 1) ~/ chunk + 1);
  }
}