How to use the @aws-sdk/util-buffer-from.fromString function in @aws-sdk/util-buffer-from

To help you get started, we’ve selected a few @aws-sdk/util-buffer-from examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-sdk-js-v3 / packages / hash-node / src / index.spec.ts View on Github external
it(`should calculate a ${supportedHash} hmac of ${expected} for an input of ${data} and a key of ${key}`, async () => {
          const hash = new Hash(supportedHash, fromString(key, "hex"));
          hash.update(fromString(data, "hex"));
          const { buffer } = await hash.digest();
          expect(fromArrayBuffer(buffer).toString("hex")).toMatch(expected);
        });
      }
github aws / aws-sdk-js-v3 / packages / hash-node / src / index.spec.ts View on Github external
it(`should calculate a ${supportedHash} hash of ${expected} for an input of ${input}`, async () => {
          const hash = new Hash(supportedHash);
          hash.update(fromString(input, "base64"));
          const { buffer } = await hash.digest();
          expect(fromArrayBuffer(buffer).toString("hex")).toBe(expected);
        });
      }
github aws / aws-sdk-js-v3 / packages / hash-node / src / index.spec.ts View on Github external
it(`should calculate a ${supportedHash} hmac of ${expected} for an input of ${data} and a key of ${key}`, async () => {
          const hash = new Hash(supportedHash, fromString(key, "hex"));
          hash.update(fromString(data, "hex"));
          const { buffer } = await hash.digest();
          expect(fromArrayBuffer(buffer).toString("hex")).toMatch(expected);
        });
      }
github aws / aws-sdk-js-v3 / packages / util-utf8-node / src / index.ts View on Github external
export function fromUtf8(input: string): Uint8Array {
  const buf = fromString(input, "utf8");

  return new Uint8Array(
    buf.buffer,
    buf.byteOffset,
    buf.byteLength / Uint8Array.BYTES_PER_ELEMENT
  );
}
github aws / aws-sdk-js-v3 / packages / hash-node / src / index.ts View on Github external
function castSourceData(toCast: SourceData, encoding?: string): Buffer {
  if (Buffer.isBuffer(toCast)) {
    return toCast;
  }

  if (typeof toCast === "string") {
    return fromString(toCast, encoding);
  }

  if (ArrayBuffer.isView(toCast)) {
    return fromArrayBuffer(toCast.buffer, toCast.byteOffset, toCast.byteLength);
  }

  return fromArrayBuffer(toCast);
}
github aws / aws-sdk-js-v3 / packages / util-base64-node / src / index.ts View on Github external
export function fromBase64(input: string): Uint8Array {
  const buffer = fromString(input, "base64");

  return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
}

@aws-sdk/util-buffer-from

[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-buffer-from/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-buffer-from) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-buffer-from.svg)](https://www.npmjs.com/package/@aws

Apache-2.0
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis

Similar packages