rsa-oaep-encryption
    Preparing search index...

    Class ByteStringBuffer

    A binary string backed byte buffer for efficient binary data manipulation.

    This class provides methods for reading and writing binary data using JavaScript strings as the underlying storage. Each character in the string represents one byte (0-255).

    import { ByteStringBuffer } from 'rsa-oaep-encryption';

    // Create a buffer and write some bytes
    const buffer = new ByteStringBuffer();
    buffer.putByte(0x48); // 'H'
    buffer.putByte(0x69); // 'i'

    // Read bytes back
    console.log(buffer.toHex()); // "4869"
    console.log(buffer.toArrayBuffer()); // ArrayBuffer with [0x48, 0x69]

    // Create from existing binary string
    const buffer2 = new ByteStringBuffer('\x00\x01\x02\x03');
    console.log(buffer2.length()); // 4
    console.log(buffer2.getByte()); // 0
    Index

    Constructors

    Properties

    read: number = 0

    Methods

    • Gets a byte at the given index without modifying the read pointer.

      Parameters

      • i: number

        the byte index.

      Returns number

      the byte.

    • Gets a binary encoded string of the bytes from this buffer without modifying the read pointer.

      Parameters

      • Optionalcount: number

        the number of bytes to get, omit to get all.

      Returns string

      a string full of binary encoded characters.

    • Gets a byte from this buffer and advances the read pointer by 1.

      Returns number

      the byte.

    • Reads bytes out as a binary encoded string and clears them from the buffer. Note that the resulting string is binary encoded (in node.js this encoding is referred to as binary, it is not utf8).

      Parameters

      • Optionalcount: number

        the number of bytes to read, undefined or null for all.

      Returns string

      a binary encoded string of bytes.

    • Gets an n-bit integer from this buffer in big-endian order and advances the read pointer by ceil(n/8).

      Parameters

      • n: 8 | 16 | 24 | 32

        the number of bits in the integer (8, 16, 24, or 32).

      Returns number

      the integer.

    • Gets a uint32 from this buffer in big-endian order and advances the read pointer by 4.

      Returns number

      the word.

    • Gets the number of bytes in this buffer.

      Returns number

      the number of bytes in this buffer.

    • Puts a byte in this buffer.

      Parameters

      • b: number

        the byte to put.

      Returns this

      this buffer.

    • Puts bytes in this buffer.

      Parameters

      • bytes: string

        the bytes (as a binary encoded string) to put.

      Returns this

      this buffer.

    • Puts a 32-bit integer in this buffer in big-endian order.

      Parameters

      • i: number

        the 32-bit integer.

      Returns this

      this buffer.

    • Converts this buffer to an ArrayBuffer.

      Returns ArrayBuffer

      An ArrayBuffer.

    • Converts this buffer to a hexadecimal string.

      Returns string

      a hexadecimal string.