### Install py-pkpass from GitHub Source: https://pypi.org/project/py-pkpass Install the py-pkpass fork directly from GitHub using pip. This is useful for obtaining the latest development version. ```bash pip install git+https://github.com/GlitchOo/py-pkpass.git ``` -------------------------------- ### Install py-pkpass using pip Source: https://pypi.org/project/py-pkpass Install the py-pkpass library from PyPI using pip. This is the standard method for installing the latest stable release. ```bash pip install py-pkpass ``` -------------------------------- ### Run Tests Source: https://pypi.org/project/py-pkpass Execute the project's tests using pytest. This command runs pytest in verbose mode. ```bash python -m pytest -v ``` -------------------------------- ### Generate Apple Wallet Pass (.pkpass) Source: https://pypi.org/project/py-pkpass This Python script demonstrates how to create a Store Card pass, including adding primary fields, a barcode, NFC support, and visual styling. It then generates the .pkpass file using provided certificate and key files. ```python #!/usr/bin/env python from py_pkpass.models import Pass, Barcode, BarcodeFormat, StoreCard # Create a store card pass type cardInfo = StoreCard() cardInfo.addPrimaryField('name', 'John Doe', 'Name') # Pass certificate information organizationName = 'Your organization' passTypeIdentifier = 'pass.com.your.organization' teamIdentifier = 'AGK5BZEN3E' # Create the Pass object with the required identifiers passfile = Pass( cardInfo, passTypeIdentifier=passTypeIdentifier, organizationName=organizationName, teamIdentifier=teamIdentifier ) # Set required pass information passfile.serialNumber = '1234567' passfile.description = 'Sample Pass' # Add a barcode - all supported formats: PDF417, QR, AZTEC, CODE128 passfile.barcode = Barcode( message='Barcode message', format=BarcodeFormat.CODE128, altText='Alternate text' ) # Optional: Add NFC support nfc_message = "NFCURL:https://example.com/nfc" encryption_key = "MIIBCgKCAQEAxDvx..." # Your public encryption key passfile.nfc_message = nfc_message passfile.encryption_public_key = encryption_key passfile.requiresAuthentication = True # Optional: Set colors passfile.backgroundColor = "rgb(61, 152, 60)" passfile.foregroundColor = "rgb(255, 255, 255)" passfile.labelColor = "rgb(255, 255, 255)" # Optional: Prevent sharing (disables AirDrop and similar features) passfile.sharingProhibited = True # Including the icon and logo is necessary for the passbook to be valid passfile.addFile('icon.png', open('images/icon.png', 'rb')) passfile.addFile('logo.png', open('images/logo.png', 'rb')) # Create and output the Passbook file (.pkpass) password = '123456' passfile.create( 'certificate.pem', 'private.key', 'wwdr.pem', password, 'test.pkpass' ) ``` -------------------------------- ### Export Private Key from P12 File Source: https://pypi.org/project/py-pkpass Use this command to export the private key from a .p12 file into a PEM format. Ensure you have the correct export password. ```bash # Export private key from p12 file openssl pkcs12 -in "Certificates.p12" -nocerts -out private.key ``` -------------------------------- ### Export Certificate from P12 File Source: https://pypi.org/project/py-pkpass Use this command to export the certificate from a .p12 file into a PEM format. Ensure you have the correct export password. ```bash # Export certificate from p12 file openssl pkcs12 -in "Certificates.p12" -clcerts -nokeys -out certificate.pem ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.