Sample code for 30+ languages & platforms
Go

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Go Downloads

Go
    success := false

    cert := chilkat.NewCert()

    success = cert.LoadPfxFile("c:/pfx_files/my.pfx","password")
    if success != true {
        fmt.Println(cert.LastErrorText())
        cert.DisposeCert()
        return
    }

    decrypt := chilkat.NewCrypt2()
    decrypt.SetCryptAlgorithm("pki")

    success = decrypt.SetDecryptCert(cert)
    if success != true {
        fmt.Println(decrypt.LastErrorText())
        cert.DisposeCert()
        decrypt.DisposeCrypt2()
        return
    }

    bd := chilkat.NewBinData()
    success = bd.LoadFile("c:/someDir/pkcs7_encrypted.dat")

    success = decrypt.DecryptBd(bd)
    if success != true {
        fmt.Println(decrypt.LastErrorText())
        cert.DisposeCert()
        decrypt.DisposeCrypt2()
        bd.DisposeBinData()
        return
    }

    // bd contains the decrypted content.

    cert.DisposeCert()
    decrypt.DisposeCrypt2()
    bd.DisposeBinData()