Skip to main content

A small Python 3 library for decoding .NET viewstate. Can be used in various scraping scenarios.

https://travis-ci.org/yuvadm/viewstate.svg?branch=master

Install

$ pip install viewstate

Usage

The Viewstate decoder accepts Base64 encoded .NET viewstate data and returns the decoded output in the form of plain Python objects.

There are two main ways to use this package. First, it can be used as an imported library with the following typical use case:

>>> from viewstate import ViewState
>>> base64_encoded_viewstate = '/wEPBQVhYmNkZQ9nAgE='
>>> vs = ViewState(base64_encoded_viewstate)
>>> vs.decode()
('abcde', (True, 1))

It is also possible to feed the raw bytes directly:

>>> vs = ViewState(raw=b'\xff\x01....')

Alternatively, the library can be used via command line by directly executing the module:

$ cat data.base64 | python -m viewstate

Which will pretty-print the decoded data structure.

Viewstate HMAC signatures are also supported. In case there are any remaining bytes after parsing, they are assumed to be HMAC signatures, with the types estimated according to signature length.

>>> vs = ViewState(signed_view_state)
>>> vs.decode()
>>> vs.mac
'hmac_sha256'
>>> vs.signature
b'....'

Development

$ pytest

References

License

MIT

Download files

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

Source Distribution

viewstate-0.3.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viewstate-0.3.1-py2.py3-none-any.whl (7.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file viewstate-0.3.1.tar.gz.

File metadata

  • Download URL: viewstate-0.3.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for viewstate-0.3.1.tar.gz
Algorithm Hash digest
SHA256 60c398dd6507ee522f18a1c6b980d1335e5af37809cae98358e60f18954a8adc
MD5 fde506209f6960a78744c912f2553b21
BLAKE2b-256 9a2bcf4d8c23487a5455814a24357f41ce9f2dec168a300e77a624df3cec4805

See more details on using hashes here.

File details

Details for the file viewstate-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for viewstate-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2a3ee95fb5a940aa944d1f113715547a54cd14764e7a9bbeda7682696c03e7f8
MD5 7f6726c851f1e3381e8a7cc9cb1c8072
BLAKE2b-256 38cc2d416125a089f8418bf44e8819e48bcc6a0a832777dac6a5516e4164202b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.0

2 files

0.5.3

1 file

0.5.2

1 file

0.5.1

1 file

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.1

1 file

0.2.0

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page