# Signing script example

**URL:** <https://community.zymbit.com/t/signing-script-example/1266>\
**Category:** ZYMKEY4\
**Created:** [August 31, 2021, 2:01pm UTC](https://community.zymbit.com/t/signing-script-example/1266 "2021-08-31T14:01:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Alberto](https://community.zymbit.com/u/Alberto)\
**Post date:** [August 31, 2021, 2:01pm UTC](https://community.zymbit.com/t/signing-script-example/1266/1 "2021-08-31T14:01:04Z")

</div>

Regarding with signing playload capabilities on Zymkey 4 I would like to get an example of python script using sign\_digest() class.

Thanks

Regards

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [August 31, 2021, 2:20pm UTC](https://community.zymbit.com/t/signing-script-example/1266/2 "2021-08-31T14:20:39Z")

</div>

Here is a simple example:

```auto
#!/usr/bin/python3

import zymkey
import hashlib

if __name__ == " __main__":

    # Example of sign_digest() and verify_digest()
    hash_object = hashlib.sha256(b'hello world')

    print('Signing data with Zymkey ECDSA private key...', end='')
    signature = zymkey.client.sign_digest(hash_object, slot=0)
    print('OK')

    print('Verifying good data...', end='')
    zymkey.client.verify_digest(hash_object, signature, raise_exception=True, pubkey_slot=0)
    print('OK')

    print('Verifying bad data...', end='')
    bad_hash_object = hashlib.sha256(b'this does not match')
    try:
        zymkey.client.verify_digest(bad_hash_object, signature, raise_exception=True, pubkey_slot=0)
    except VerificationError:
        print('Verification failed (Expected)')
    else:
        raise Exception('verification should have failed, but passed')

```
