Skip to content

ISCC - Instance-Code#

A data checksum.

gen_instance_code(stream, bits = 64) #

Create an ISCC Instance-Code with the latest standard algorithm.

Parameters:

Name Type Description Default
stream Stream

Binary data stream for Instance-Code generation

required
bits int

Bit-length resulting Instance-Code (multiple of 64)

64

Returns:

Type Description
dict

ISCC object with properties: iscc, datahash, filesize

gen_instance_code_v0(stream, bits = 64) #

Create an ISCC Instance-Code with algorithm v0.

Parameters:

Name Type Description Default
stream Stream

Binary data stream for Instance-Code generation

required
bits int

Bit-length of resulting Instance-Code (multiple of 64)

64

Returns:

Type Description
dict

ISCC object with Instance-Code and properties: datahash, filesize

hash_instance_v0(stream) #

Create 256-bit hash digest for the Instance-Code body

Parameters:

Name Type Description Default
stream Stream

Binary data stream for hash generation.

required

Returns:

Type Description
bytes

256-bit Instance-Hash digest used as body of Instance-Code

InstanceHasher #

Incremental Instance-Hash generator.

push(self, data) #

Push data to the Instance-Hash generator.

Parameters:

Name Type Description Default
data Data

Data to be hashed

required

digest(self) #

Return Instance-Hash

Returns:

Type Description
bytes

Instance-Hash digest

multihash(self) #

Return blake3 multihash

Returns:

Type Description
str

Blake3 hash as base32 endoded 256-bit multihash

code(self, bits = 64) #

Encode digest as an ISCC Instance-Code component.

Parameters:

Name Type Description Default
bits int

Number of bits for the ISCC Instance-Code

64

Returns:

Type Description
str

ISCC Instance-Code

InstanceHasherV0 #

Incremental Instance-Hash generator.

push(self, data) #

Push data to the Instance-Hash generator.

Parameters:

Name Type Description Default
data Data

Data to be hashed

required

digest(self) #

Return Instance-Hash

Returns:

Type Description
bytes

Instance-Hash digest

multihash(self) #

Return blake3 multihash

Returns:

Type Description
str

Blake3 hash as base32 endoded 256-bit multihash

code(self, bits = 64) #

Encode digest as an ISCC Instance-Code component.

Parameters:

Name Type Description Default
bits int

Number of bits for the ISCC Instance-Code

64

Returns:

Type Description
str

ISCC Instance-Code