File manager - Edit - /home/u478019808/domains/bestandroidphones.store/public_html/static/img/logo/source.zip
Back
PK ���Zh�Ml� � make_predefined_table.pynu �[��� from __future__ import print_function import numbers import crcmod.predefined table_data = [ [ "Name", 'name', 32, ], [ "Polynomial", 'poly', 22, ], [ "Reversed?", 'reverse', 10, ], [ "Init-value", 'init', 20, ], [ "XOR-out", 'xor_out', 20, ], [ "Check", 'check', 20, ], ] ccitt_defns = [ 'kermit', 'crc-ccitt-false', 'crc-aug-ccitt', ] column_dashes = ' '.join(('=' * table_data_item[2] for table_data_item in table_data)) print(column_dashes) print(' '.join(("%-*s" % (table_data_item[2], table_data_item[0]) for table_data_item in table_data)).strip()) print(column_dashes) for defn in crcmod.predefined._crc_definitions: poly_width = crcmod.crcmod._verifyPoly(defn['poly']) hex_width = (poly_width + 3) // 4 defn_data_list = [] for (header_text, key, width) in table_data: if isinstance(defn[key], bool): item = "%s" % (defn[key],) elif isinstance(defn[key], numbers.Integral): item = "0x%0*X" % (hex_width, defn[key]) else: item = "``%s``" % (defn[key]) if defn['name'] in ccitt_defns: item = ' '.join([item, '[#ccitt]_']) item = "%-*s" % (width, item) defn_data_list.append(item) print(' '.join(defn_data_list).strip()) print(column_dashes) PK ���Z��� � intro.rstnu �[��� ============ Introduction ============ The software in this package is a Python module for generating objects that compute the Cyclic Redundancy Check (CRC). It includes a (optional) C extension for fast calculation, as well as a pure Python implementation. There is no attempt in this package to explain how the CRC works. There are a number of resources on the web that give a good explanation of the algorithms. Just do a Google search for "crc calculation" and browse till you find what you need. Another resource can be found in chapter 20 of the book "Numerical Recipes in C" by Press et. al. This package allows the use of any 8, 16, 24, 32, or 64 bit CRC. You can generate a Python function for the selected polynomial or an instance of the :class:`crcmod.Crc` class which provides the same interface as the :mod:`hashlib`, :mod:`md5` and :mod:`sha` modules from the Python standard library. A :class:`crcmod.Crc` class instance can also generate C/C++ source code that can be used in another application. ---------- Guidelines ---------- Documentation is available here as well as from the doc strings. It is up to you to decide what polynomials to use in your application. Some common CRC algorithms are predefined in :mod:`crcmod.predefined`. If someone has not specified the polynomials to use, you will need to do some research to find one suitable for your application. Examples are available in the unit test script :file:`test.py`. If you need to generate code for another language, I suggest you subclass the :class:`crcmod.Crc` class and replace the method :meth:`crcmod.Crc.generateCode`. Use :meth:`crcmod.Crc.generateCode` as a model for the new version. ------------ Dependencies ------------ Python Version ^^^^^^^^^^^^^^ The package has separate code to support the 2.x and 3.x Python series. For the 2.x versions of Python, these versions have been tested: * 2.4 * 2.5 * 2.6 * 2.7 It may still work on earlier versions of Python 2.x, but these have not been recently tested. For the 3.x versions of Python, these versions have been tested: * 3.1 Building C extension ^^^^^^^^^^^^^^^^^^^^ To build the C extension, the appropriate compiler tools for your platform must be installed. Refer to the Python documentation for building C extensions for details. ------------ Installation ------------ The :mod:`crcmod` package is installed using :mod:`distutils`. Run the following command:: python setup.py install If the extension module builds, it will be installed. Otherwise, the installation will include the pure Python version. This will run significantly slower than the extension module but will allow the package to be used. For Windows users who want to use the mingw32 compiler, run this command:: python setup.py build --compiler=mingw32 install For Python 3.x, the install process is the same but you need to use the 3.x interpreter. ------------ Unit Testing ------------ The :mod:`crcmod` package has a module :mod:`crcmod.test`, which contains unit tests for both :mod:`crcmod` and :mod:`crcmod.predefined`. When you first install :mod:`crcmod`, you should run the unit tests to make sure everything is installed properly. The test script performs a number of tests including a comparison to the direct method which uses a class implementing polynomials over the integers mod 2. To run the unit tests on Python >=2.5:: python -m crcmod.test Alternatively, in the :file:`test` directory run:: python test_crcmod.py --------------- Code Generation --------------- The :mod:`crcmod` package is capable of generating C functions that can be compiled with a C or C++ compiler. In the :file:`test` directory, there is an :file:`examples.py` script that demonstrates how to use the code generator. The result of this is written out to the file :file:`examples.c`. The generated code was checked to make sure it compiles with the GCC compiler. ------- License ------- The :mod:`crcmod` package is released under the MIT license. See the :file:`LICENSE` file for details. ---------- References ---------- .. seealso:: :func:`binascii.crc32` function from the :mod:`binascii` module CRC-32 implementation :func:`zlib.crc32` function from the :mod:`zlib` module CRC-32 implementation Module :mod:`hashlib` Secure hash and message digest algorithms. Module :mod:`md5` RSA's MD5 message digest algorithm. Module :mod:`sha` NIST's secure hash algorithm, SHA. Module :mod:`hmac` Keyed-hashing for message authentication. PK ���Z��f�� � index.rstnu �[��� .. crcmod documentation master file, created by sphinx-quickstart on Thu Jan 21 14:04:12 2010. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. crcmod documentation ==================== This is the documentation for the :mod:`crcmod` Python library. .. toctree:: :maxdepth: 2 intro.rst crcmod.rst crcmod.predefined.rst * :ref:`genindex` * :ref:`modindex` * :ref:`search` PK ���Z�*� conf.pynu �[��� # -*- coding: utf-8 -*- # # crcmod documentation build configuration file, created by # sphinx-quickstart on Thu Jan 21 14:04:12 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.intersphinx', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'crcmod' copyright = u'2010, Raymond L Buvel' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1.7' # The full version, including alpha/beta/rc tags. release = '1.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'crcmoddoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'crcmod.tex', u'crcmod Documentation', u'Raymond L Buvel', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. #epub_title = '' #epub_author = '' #epub_publisher = '' #epub_copyright = '' # The language of the text. It defaults to the language option # or en if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. #epub_exclude_files = [] # -- Options for intersphinx -------------------------------------------------- intersphinx_mapping = {'http://docs.python.org/': None} PK ���ZZ嘸 � Makefilenu �[��� # Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp epub latex changes linkcheck doctest help: @echo "Please use \`make <target>' where <target> is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/crcmod.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/crcmod.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) _build/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/crcmod" @echo "# ln -s _build/devhelp $$HOME/.local/share/devhelp/crcmod" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." latexpdf: latex $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex @echo "Running LaTeX files through pdflatex..." make -C _build/latex all-pdf @echo "pdflatex finished; the PDF files are in _build/latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." PK ���Z��Y� � make.batnu �[��� @ECHO OFF REM Command file for Sphinx documentation set SPHINXBUILD=sphinx-build set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^<target^>` where ^<target^> is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\crcmod.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\crcmod.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% _build/devhelp echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end PK ���Z �v�-! -! crcmod.rstnu �[��� :mod:`crcmod` -- CRC calculation ================================ .. module:: crcmod :synopsis: CRC calculation .. moduleauthor:: Raymond L Buvel .. sectionauthor:: Craig McQueen This module provides a function factory :func:`mkCrcFun` and a class :class:`Crc` for calculating CRCs of byte strings using common CRC algorithms. .. note:: This documentation normally shows Python 2.x usage. Python 3.x usage is very similar, with the main difference that input strings must be explicitly defined as :keyword:`bytes` type, or an object that supports the buffer protocol. E.g.:: >>> crc_value = crc_function(b'123456789') >>> crc_value = crc_function(bytearray((49, 50, 51, 52, 53, 54, 55, 56, 57))) :func:`mkCrcFun` -- CRC function factory ---------------------------------------- The function factory provides a simple interface for CRC calculation. .. function:: mkCrcFun(poly[, initCrc, rev, xorOut]) Function factory that returns a new function for calculating CRCs using a specified CRC algorithm. :param poly: The generator polynomial to use in calculating the CRC. The value is specified as a Python integer or long integer. The bits in this integer are the coefficients of the polynomial. The only polynomials allowed are those that generate 8, 16, 24, 32, or 64 bit CRCs. :param initCrc: Initial value used to start the CRC calculation. This initial value should be the initial shift register value, reversed if it uses a reversed algorithm, and then XORed with the final XOR value. That is equivalent to the CRC result the algorithm should return for a zero-length string. Defaults to all bits set because that starting value will take leading zero bytes into account. Starting with zero will ignore all leading zero bytes. :param rev: A flag that selects a bit reversed algorithm when :keyword:`True`. Defaults to :keyword:`True` because the bit reversed algorithms are more efficient. :param xorOut: Final value to XOR with the calculated CRC value. Used by some CRC algorithms. Defaults to zero. :return: CRC calculation function :rtype: function The function that is returned is as follows: .. function:: .crc_function(data[, crc=initCrc]) :param data: Data for which to calculate the CRC. :type data: byte string :param crc: Initial CRC value. :return: Calculated CRC value. :rtype: integer Examples ^^^^^^^^ **CRC-32** Example:: >>> import crcmod >>> crc32_func = crcmod.mkCrcFun(0x104c11db7, initCrc=0, xorOut=0xFFFFFFFF) >>> hex(crc32_func('123456789')) '0xcbf43926L' The CRC-32 uses a "reversed" algorithm, used for many common CRC algorithms. Less common is the non-reversed algorithm, as used by the 16-bit **XMODEM** CRC:: >>> xmodem_crc_func = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000) >>> hex(xmodem_crc_func('123456789')) '0x31c3' The CRC function can be called multiple times. On subsequent calls, pass the CRC value previously calculated as a second parameter:: >>> crc_value = crc32_func('1234') >>> crc_value = crc32_func('56789', crc_value) >>> hex(crc_value) '0xcbf43926L' Python 3.x example: Unicode strings are not accepted as input. Byte strings are acceptable. You may calculate a CRC for an object that implements the buffer protocol:: >>> import crcmod >>> crc32_func = crcmod.mkCrcFun(0x104c11db7, initCrc=0, xorOut=0xFFFFFFFF) >>> hex(crc32_func('123456789')) ... TypeError: Unicode-objects must be encoded before calculating a CRC >>> hex(crc32_func(b'123456789')) '0xcbf43926' >>> hex(crc32_func(bytearray((49, 50, 51, 52, 53, 54, 55, 56, 57)))) '0xcbf43926' Class :class:`Crc` ------------------ The class provides an interface similar to the Python :mod:`hashlib`, :mod:`md5` and :mod:`sha` modules. .. class:: Crc(poly[, initCrc, rev, xorOut]) Returns a new :class:`Crc` object for calculating CRCs using a specified CRC algorithm. The parameters are the same as those for the factory function :func:`mkCrcFun`. :param poly: The generator polynomial to use in calculating the CRC. The value is specified as a Python integer or long integer. The bits in this integer are the coefficients of the polynomial. The only polynomials allowed are those that generate 8, 16, 24, 32, or 64 bit CRCs. :param initCrc: Initial value used to start the CRC calculation. This initial value should be the initial shift register value, reversed if it uses a reversed algorithm, and then XORed with the final XOR value. That is equivalent to the CRC result the algorithm should return for a zero-length string. Defaults to all bits set because that starting value will take leading zero bytes into account. Starting with zero will ignore all leading zero bytes. :param rev: A flag that selects a bit reversed algorithm when :keyword:`True`. Defaults to :keyword:`True` because the bit reversed algorithms are more efficient. :param xorOut: Final value to XOR with the calculated CRC value. Used by some CRC algorithms. Defaults to zero. :class:`Crc` objects contain the following constant values: .. attribute:: digest_size The size of the resulting digest in bytes. This depends on the width of the CRC polynomial. E.g. for a 32-bit CRC, :data:`digest_size` will be ``4``. .. attribute:: crcValue The calculated CRC value, as an integer, for the data that has been input using :meth:`update`. This value is updated after each call to :meth:`update`. :class:`Crc` objects support the following methods: .. method:: new([arg]) Create a new instance of the :class:`Crc` class initialized to the same values as the original instance. The CRC value is set to the initial value. If a string is provided in the optional ``arg`` parameter, it is passed to the :meth:`update` method. .. method:: copy() Create a new instance of the :class:`Crc` class initialized to the same values as the original instance. The CRC value is copied from the current value. This allows multiple CRC calculations using a common initial string. .. method:: update(data) :param data: Data for which to calculate the CRC :type data: byte string Update the calculated CRC value for the specified input data. .. method:: digest() Return the current CRC value as a string of bytes. The length of this string is specified in the :attr:`digest_size` attribute. .. method:: hexdigest() Return the current CRC value as a string of hex digits. The length of this string is twice the :attr:`digest_size` attribute. .. method:: generateCode(functionName, out, [dataType, crcType]) Generate a C/C++ function. :param functionName: String specifying the name of the function. :param out: An open file-like object with a write method. This specifies where the generated code is written. :param dataType: An optional parameter specifying the data type of the input data to the function. Defaults to ``UINT8``. :param crcType: An optional parameter specifying the data type of the CRC value. Defaults to one of ``UINT8``, ``UINT16``, ``UINT32``, or ``UINT64`` depending on the size of the CRC value. Examples ^^^^^^^^ **CRC-32** Example:: >>> import crcmod >>> crc32 = crcmod.Crc(0x104c11db7, initCrc=0, xorOut=0xFFFFFFFF) >>> crc32.update('123456789') >>> hex(crc32.crcValue) '0xcbf43926L' >>> crc32.hexdigest() 'CBF43926' The :meth:`Crc.update` method can be called multiple times, and the CRC value is updated with each call:: >>> crc32new = crc32.new() >>> crc32new.update('1234') >>> crc32new.hexdigest() '9BE3E0A3' >>> crc32new.update('56789') >>> crc32new.hexdigest() 'CBF43926' PK ���Zy��}$ $ crcmod.predefined.rstnu �[��� :mod:`crcmod.predefined` -- CRC calculation using predefined algorithms ======================================================================= .. module:: crcmod.predefined :synopsis: CRC calculation using predefined algorithms .. moduleauthor:: Craig McQueen .. sectionauthor:: Craig McQueen This module provides a function factory :func:`mkPredefinedCrcFun` and a class :class:`PredefinedCrc` for calculating CRCs of byte strings using common predefined CRC algorithms. The function factory and the class are very similar to those defined in :mod:`crcmod`, except that the CRC algorithm is specified by a predefined name, rather than the individual polynomial, reflection, and initial and final-XOR parameters. Predefined CRC algorithms ------------------------- The :mod:`crcmod.predefined` module offers the following predefined algorithms: ================================ ====================== ========== ==================== ==================== ==================== Name Polynomial Reversed? Init-value XOR-out Check ================================ ====================== ========== ==================== ==================== ==================== ``crc-8`` 0x107 False 0x00 0x00 0xF4 ``crc-8-darc`` 0x139 True 0x00 0x00 0x15 ``crc-8-i-code`` 0x11D False 0xFD 0x00 0x7E ``crc-8-itu`` 0x107 False 0x55 0x55 0xA1 ``crc-8-maxim`` 0x131 True 0x00 0x00 0xA1 ``crc-8-rohc`` 0x107 True 0xFF 0x00 0xD0 ``crc-8-wcdma`` 0x19B True 0x00 0x00 0x25 ``crc-16`` 0x18005 True 0x0000 0x0000 0xBB3D ``crc-16-buypass`` 0x18005 False 0x0000 0x0000 0xFEE8 ``crc-16-dds-110`` 0x18005 False 0x800D 0x0000 0x9ECF ``crc-16-dect`` 0x10589 False 0x0001 0x0001 0x007E ``crc-16-dnp`` 0x13D65 True 0xFFFF 0xFFFF 0xEA82 ``crc-16-en-13757`` 0x13D65 False 0xFFFF 0xFFFF 0xC2B7 ``crc-16-genibus`` 0x11021 False 0x0000 0xFFFF 0xD64E ``crc-16-maxim`` 0x18005 True 0xFFFF 0xFFFF 0x44C2 ``crc-16-mcrf4xx`` 0x11021 True 0xFFFF 0x0000 0x6F91 ``crc-16-riello`` 0x11021 True 0x554D 0x0000 0x63D0 ``crc-16-t10-dif`` 0x18BB7 False 0x0000 0x0000 0xD0DB ``crc-16-teledisk`` 0x1A097 False 0x0000 0x0000 0x0FB3 ``crc-16-usb`` 0x18005 True 0x0000 0xFFFF 0xB4C8 ``x-25`` 0x11021 True 0x0000 0xFFFF 0x906E ``xmodem`` 0x11021 False 0x0000 0x0000 0x31C3 ``modbus`` 0x18005 True 0xFFFF 0x0000 0x4B37 ``kermit`` [#ccitt]_ 0x11021 True 0x0000 0x0000 0x2189 ``crc-ccitt-false`` [#ccitt]_ 0x11021 False 0xFFFF 0x0000 0x29B1 ``crc-aug-ccitt`` [#ccitt]_ 0x11021 False 0x1D0F 0x0000 0xE5CC ``crc-24`` 0x1864CFB False 0xB704CE 0x000000 0x21CF02 ``crc-24-flexray-a`` 0x15D6DCB False 0xFEDCBA 0x000000 0x7979BD ``crc-24-flexray-b`` 0x15D6DCB False 0xABCDEF 0x000000 0x1F23B8 ``crc-32`` 0x104C11DB7 True 0x00000000 0xFFFFFFFF 0xCBF43926 ``crc-32-bzip2`` 0x104C11DB7 False 0x00000000 0xFFFFFFFF 0xFC891918 ``crc-32c`` 0x11EDC6F41 True 0x00000000 0xFFFFFFFF 0xE3069283 ``crc-32d`` 0x1A833982B True 0x00000000 0xFFFFFFFF 0x87315576 ``crc-32-mpeg`` 0x104C11DB7 False 0xFFFFFFFF 0x00000000 0x0376E6E7 ``posix`` 0x104C11DB7 False 0xFFFFFFFF 0xFFFFFFFF 0x765E7680 ``crc-32q`` 0x1814141AB False 0x00000000 0x00000000 0x3010BF7F ``jamcrc`` 0x104C11DB7 True 0xFFFFFFFF 0x00000000 0x340BC6D9 ``xfer`` 0x1000000AF False 0x00000000 0x00000000 0xBD0BE338 ``crc-64`` 0x1000000000000001B True 0x0000000000000000 0x0000000000000000 0x46A5A9388A5BEFFE ``crc-64-we`` 0x142F0E1EBA9EA3693 False 0x0000000000000000 0xFFFFFFFFFFFFFFFF 0x62EC59E3F1A4F00A ``crc-64-jones`` 0x1AD93D23594C935A9 True 0xFFFFFFFFFFFFFFFF 0x0000000000000000 0xCAA717168609F281 ================================ ====================== ========== ==================== ==================== ==================== .. rubric:: Notes .. [#ccitt] Definitions of CCITT are disputable. See: * http://homepages.tesco.net/~rainstorm/crc-catalogue.htm * http://web.archive.org/web/20071229021252/http://www.joegeluso.com/software/articles/ccitt.htm :func:`mkPredefinedCrcFun` -- CRC function factory -------------------------------------------------- The function factory provides a simple interface for CRC calculation. It is similar to :func:`crcmod.mkCrcFun`, except that it specifies a CRC algorithm by name rather than its parameters. .. function:: mkPredefinedCrcFun(crc_name) Function factory that returns a new function for calculating CRCs using a specified CRC algorithm. :param crc_name: The name of the predefined CRC algorithm to use. :type crc_name: string :return: CRC calculation function :rtype: function The function that is returned is the same as that returned by :func:`crcmod.mkCrcFun`: .. function:: .crc_function(data[, crc=initCrc]) :param data: Data for which to calculate the CRC. :type data: byte string :param crc: Initial CRC value. :return: Calculated CRC value. :rtype: integer .. function:: mkCrcFun(crc_name) This is an alias for :func:`crcmod.predefined.mkPredefinedCrcFun`. However, it is not defined when :mod:`crcmod.predefined` is imported using the form:: >>> from crcmod.predefined import * Examples ^^^^^^^^ **CRC-32** example:: >>> import crcmod.predefined >>> crc32_func = crcmod.predefined.mkCrcFun('crc-32') >>> hex(crc32_func('123456789')) '0xcbf43926L' **XMODEM** example:: >>> xmodem_crc_func = crcmod.predefined.mkCrcFun('xmodem') >>> hex(xmodem_crc_func('123456789')) '0x31c3' Class :class:`PredefinedCrc` ---------------------------- This class is inherited from the :class:`crcmod.Crc` class, and is the same except for the initialization. It specifies a CRC algorithm by name rather than its parameters. .. class:: PredefinedCrc(crc_name) Returns a new :class:`Crc` object for calculating CRCs using a specified CRC algorithm. The parameter is the same as that for the factory function :func:`crcmod.predefined.mkPredefinedCrcFun`. :param crc_name: The name of the predefined CRC algorithm to use. :type crc_name: string .. class:: Crc(poly[, initCrc, rev, xorOut]) This is an alias for :class:`crcmod.predefined.PredefinedCrc`. However, it is not defined when :mod:`crcmod.predefined` is imported using the form:: >>> from crcmod.predefined import * Examples ^^^^^^^^ **CRC-32** Example:: >>> import crcmod.predefined >>> crc32 = crcmod.predefined.Crc('crc-32') >>> crc32.update('123456789') >>> hex(crc32.crcValue) '0xcbf43926L' >>> crc32.hexdigest() 'CBF43926' PK ���Zh�Ml� � make_predefined_table.pynu �[��� PK ���Z��� � � intro.rstnu �[��� PK ���Z��f�� � � index.rstnu �[��� PK ���Z�*� � conf.pynu �[��� PK ���ZZ嘸 � '8 Makefilenu �[��� PK ���Z��Y� � I make.batnu �[��� PK ���Z �v�-! -! <X crcmod.rstnu �[��� PK ���Zy��}$ $ �y crcmod.predefined.rstnu �[��� PK ` ��
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings