Skip to main content

DRB Magic Signature

Project description

Magic Signature

This signature implementation allows to recognize a drb topic thanks to its magic field. The magic field is a fixed set of bytes in a data file to characterize its format. For example PKzip files always starts with '\x50\x4b\x03\x04'.

Using this module

To include this module into your project, the drb-signature-magic module shall be referenced into requirements.txt file, or the following pip line can be run:

pip install drb-signature-magic

Magic Signature definition

The signature have a type, a pattern and eventually an offset.

Type

Can be

  • bytes
  • string
  • hexa
  • regex

offset

It is the offset to skip before test if the signature matches. By default, it is zero, that means that the tes ti made at beginning.

pattern

After apply the offset on the stream of node.

For a string or bytes type the pattern is a value to compare.

For hexa, the pattern is converted to bytes, for example FF FE is converted to b'/xFFE/xFF'. And conversion, the behavior is the same that for bytes.

For a regex the pattern is a string that matches with string if 255 max character read.

Examples

For example to recognize PKzip that starts with '\x50\x4b\x03\x04'

id: 0225053d-4ea2-4046-bf97-af1dbac4e417
label: Test signature hexa for pkzip
category: FORMATTING
factory: pkzip
signatures:
  - magic:
      type: hexa
      pattern: 50 4b 03 04
      offset: 0

Same signature in bytes 'PK\x03\x04' (can be '\x50\x4b\x03\x04' also)

id: 0225053d-4ea2-4046-bf97-af1dbac4e417
label: Test signature bytes for pkzip
category: FORMATTING
factory: pkzip
signatures:
  - magic:
      type: bytes
      pattern: 'PK\x03\x04'
      offset: 0

For example to recognize LAS file sequence ^LAS are in position 0

id: c04f9327-3045-4fc0-93f8-b8dcd6626f64
label: Test signature magic LAS
category: FORMATTING
factory: impl_x
signatures:
  - magic:
      type: bytes
      pattern: ^LAS

For example to recognize a file defined by sequence of 6 decimal are in position 25

id: c04f9327-3045-4fc0-93f8-b8dcd6626f64
label: Test signature magic LAS
category: FORMATTING
factory: impl_x
signatures:
  - magic:
      type: bytes
      pattern: \d\d\d\d\d\d
      offset: 25

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drb-signature-magic-1.0.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

drb_signature_magic-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file drb-signature-magic-1.0.0.tar.gz.

File metadata

  • Download URL: drb-signature-magic-1.0.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for drb-signature-magic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a9be4942a12bd8dde7a0a858255c1c77f63dd775772112231ce8c9734fe34b0e
MD5 78c5e580971e4f825f49e64f457fe6b2
BLAKE2b-256 6aeb89b73dcc6b4670906107d199fb655ec777f4603638d067ca93ffc9d67eb1

See more details on using hashes here.

File details

Details for the file drb_signature_magic-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for drb_signature_magic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 faa68ae04caffde992d89a2a3f3fad93c7ace23c107cbaa0ad6fe5e3c913432f
MD5 c5b78321ca673234937322717be9ad96
BLAKE2b-256 24ee955ce193878d2d2ccb50d62dafe58d6570a65071e38ee2f5acbbdbae43d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page