How to use the buffer-crc32 function in buffer-crc32

To help you get started, we’ve selected a few buffer-crc32 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 heineiuo / rippledb / src / LogWriter.ts View on Github external
private emitPhysicalRecord = async (
    record: Buffer,
    type: RecordType
  ): Promise => {
    const head = Buffer.alloc(kHeaderSize)
    const length = record.length
    head[4] = length & 0xff
    head[5] = length >> 8
    head[6] = type
    const crc = crc32(
      Buffer.concat([Buffer.from([type]), record, Buffer.from([record.length])])
    )
    head.fill(crc, 0, 4)

    this._blockOffset += record.length + kHeaderSize
    await this.appendFile(Buffer.concat([head, record]))
  }
github heineiuo / rippledb / src / SSTableBuilder.ts View on Github external
async writeRawBlock(
    blockContent: Slice,
    type: CompressionTypes,
    handle: BlockHandle
  ): Promise {
    handle.offset = this._offset
    handle.size = blockContent.size
    await this.appendFile(blockContent.buffer)
    const trailer = Buffer.alloc(kBlockTrailerSize)
    trailer[0] = type
    const crc32buffer = crc32(
      Buffer.concat([blockContent.buffer, Buffer.from([type])])
    )
    trailer.fill(crc32buffer, 1, 5)
    await this.appendFile(trailer)
    this._offset += blockContent.size + kBlockTrailerSize
  }
github heineiuo / rippledb / src / VersionEditRecord.ts View on Github external
get buffer(): Buffer {
    const lengthBuf = Buffer.from(
      createHexStringFromDecimal(this.data.length),
      'hex'
    )
    const typeBuf = Buffer.from([this.type])
    const sum = crc32(Buffer.concat([typeBuf, this.data.buffer]))
    return Buffer.concat([sum, lengthBuf, typeBuf, this.data.buffer])
  }
}
github Rich-Harris / sorcery / src / utils / decodeMappings.js View on Github external
export default function decodeMappings ( mappings ) {
	let checksum = crc32( mappings );

	if ( !cache[ checksum ] ) {
		cache[ checksum ] = decode( mappings );
	}

	return cache[ checksum ];
}
github Emurgo / yoroi-frontend / app / api / ada / lib / cardanoCrypto / plate.js View on Github external
export function createAccountPlate(accountPubHash: string): WalletAccountNumberPlate {
  const hash = blakejs.blake2bHex(accountPubHash);
  const [a, b, c, d] = crc32(hash);
  const alpha = `ABCDEJHKLNOPSTXZ`;
  const letters = x => `${alpha[Math.floor(x / 16)]}${alpha[x % 16]}`;
  const numbers = `${((c << 8) + d) % 10000}`.padStart(4, '0');
  const id = `${letters(a)}${letters(b)}-${numbers}`;
  return { hash, id };
}

buffer-crc32

A pure javascript CRC32 algorithm that plays nice with binary data

MIT
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis

Similar packages