Giter Club home page Giter Club logo

pyrabin's Introduction

PyRabin

A python module for generating rabin fingerprints.

The C extension implementation is based on rabin-fingerprint-c with some bugs fixed.

Features

  • Fast fingerprint generation.
  • Split file into blocks according to the rabin fingerprints.
  • Window/Chunk size is configurable.

API

Module methods

  • set_prime(integer)
    • Set Rabin polynomial prime, default is 3.
  • set_window_size(integer)
    • Set Rabin polynomial sliding window size, default is 48 bytes.
  • set_max_block_size(integer)
    • Set Rabin polynomial max block size, default is 64K bytes.
  • set_min_block_size(integer)
    • Set Rabin polynomial min block size, default is 2K bytes
  • set_average_block_size(integer)
    • Set Rabin polynomial average block size, average is 8K bytes.
  • get_file_fingerprints(filename)
    • Returns a list of tupple, each tuple represents (offset, length, fingerprint)
  • split_file_by_fingerprints(filename)
    • Returns a list of tupple, each tuple represents (offset, length, fingerprint, filename).
    • The default filename is sha1sum of the chunk with '.blk' suffix.

class Rabin

  • register(callback)
    • Register a callback for calling when a block is reached
    • The callback is called with three parameters: (offset, length, fingerprint)
  • update(data)
    • Update Rabin fingerprint list by adding a block of data
  • clear()
    • Clear fingerprints and reset status
  • fingerprints()
    • Return fingerprints of all data passed by the update method

Examples

  • See test/test.sh for example

Bugs

  • Please report bugs / mis-formatted pages to the github issure tracker.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.