INNER CODE UNIT · JavaScript

resolveDigestAlgorithm

codedogQBY/ReadAny · packages/app-expo/index.js:32

function resolveDigestAlgorithm(algorithm) {
  const name = typeof algorithm === "string" ? algorithm : algorithm?.name;
  switch ((name || "").toUpperCase()) {
    case "SHA-1":
      return ExpoCrypto.CryptoDigestAlgorithm.SHA1;
    case "SHA-256":
      return ExpoCrypto.CryptoDigestAlgorithm.SHA256;
    default:
      throw new Error(`Unsupported digest algorithm: ${String(name || algorithm)}`);
  }
}

function toUint8Array(data) {
  if (data instanceof Uint8Array) {
    return data;
  }
  if (ArrayBuffer.isView(data)) {
    return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…