Skip to main content
Padding - Padding methods for password based encryption
---------------------------------------------

Append and remove padding to/from a string.

I. Functions:
appendPadding(str, blocksize=AES_blocksize, mode='CMS'):
Pad (append padding to) string for use with symmetric encryption algorithm
Input: (string) str - String to be padded
(int) blocksize - block size of the encryption algorithm. Usually 8 or 16 bytes
(string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random)
Return:(string) Padded string according to chosen padding mode

removePadding(str, blocksize=AES_blocksize, mode='CMS'):
Remove padding from string
Input: (str) str - String to be padded
(int) blocksize - block size of the algorithm. Usually 8 or 16 bytes
(string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random)
Return:(string) Decrypted string without padding

II. Blocksizes:
DES (Triple DES), CAST5 and Blowfish have block size of 64 bits = 8 bytes
DES_blocksize = 8
CAST5_blocksize = 8
Blowfish_blocksize = 8

AES has fixed block size of 128 bits = 16 bytes and this is the default blocksize
AES_blocksize = 16

III. Mode:
MODES ={
(0,'CMS') : 'Pad with bytes all of the same value as the number of padding bytes. Default mode used in Cryptographic Message Syntax (CMS as defined in RFC 5652, PKCS#5, PKCS#7 and RFC 1423 PEM)',
(1,'Bit') : 'BitPadding: Pad with 0x80 (10000000) followed by zero (null) bytes. Described in ANSI X.923 and ISO/IEC 9797-1',
(2,'ZeroLen') : 'Pad with zeroes except make the last byte equal to the number (length) of padding bytes',
(3,'Null') : 'Pad with null bytes. Only for encrypting of text data.',
(4,'Space') : 'Pad with spaces. Only for encrypting of text data.',
(5,'Random') : 'ISO 10126 Padding (withdrawn in 2007): Pad with random bytes + last byte equal to the number of padding bytes'
}

CMS mode is the default one

Examples in the README.txt file

Metadata

Release files for Padding 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Padding 0.5
File Size Uploaded Provenance Actions
Padding-0.5.tar.gz 3.9 kB Without provenance Details for Padding-0.5.tar.gz

Release files / Padding-0.5.tar.gz

Download URL Padding-0.5.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8994b4d8720b733ddf697bc27ce17b672220c48c4a37eef1e7eaa30a4ad90308
BLAKE2b-256 checksum
How to use checksums
39c6400b6f20c0679fcca2d0d7d933e142d000a707a571a9068fd8297e88a781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

Security for Padding 0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5 This release

1 release file No provenance

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