<reponame>nomhoi/pycades_build<filename>code/sample_sign_verify_detached.py
import pycades

store = pycades.Store()
store.Open(pycades.CADESCOM_CONTAINER_STORE, pycades.CAPICOM_MY_STORE,
           pycades.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED)
certs = store.Certificates
assert(certs.Count != 0), "Certificates with private key not found"

signer = pycades.Signer()
signer.Certificate = certs.Item(1)
signer.CheckCertificate = True

content = "Test content to be signed"

signedData = pycades.SignedData()
signedData.Content = content
signature = signedData.SignCades(signer, pycades.CADESCOM_CADES_BES, True)
print("--Signature--")
print(signature)
print("----")

_signedData = pycades.SignedData()
_signedData.Content = content
_signedData.VerifyCades(signature, pycades.CADESCOM_CADES_BES, True)
print("Verified successfully")

import pycades

store = pycades.Store()
store.Open(pycades.CADESCOM_CONTAINER_STORE, pycades.CAPICOM_MY_STORE,
           pycades.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED)
certs = store.Certificates
assert(certs.Count != 0), "Certificates with private key not found"

signer = pycades.Signer()
signer.Certificate = certs.Item(1)
signer.CheckCertificate = True

content = "Test content to be signed"

signedData = pycades.SignedData()
signedData.Content = content
signature = signedData.SignCades(signer, pycades.CADESCOM_CADES_BES, True)
print("--Signature--")
print(signature)
print("----")

_signedData = pycades.SignedData()
_signedData.Content = content
_signedData.VerifyCades(signature, pycades.CADESCOM_CADES_BES, True)
print("Verified successfully")