(blob, pubkey)
return x
Encrypt the given blob of data, given the public key provided.

    :return The encrypted blob.
Encrypt the given blob of data, given the public key provided.
Encrypt the given blob of data given the public key provided .
def encrypt_block(blob, pubkey):
    """
    Encrypt the given blob of data, given the public key provided.

    :return The encrypted blob.
    """
    # Make a MemoryBuffer of the message.
    inbuf = BIO.MemoryBuffer(blob)

    # Seed the PRNG.
    Rand.rand_seed(os.urandom(1024))

    # Instantiate an SMIME object.
    s = SMIME.SMIME()

    # Load target cert to encrypt to.
    x509 = X509.load_cert(pubkey)
    sk = X509.X509_Stack()
    sk.push(x509)
    s.set_x509_stack(sk)

    # Set cipher: AES 256 bit in CBC mode.
    s.set_cipher(SMIME.Cipher('aes_256_cbc'))

    # Encrypt the buffer.
    p7 = s.encrypt(inbuf)
    temp_buff = BIO.MemoryBuffer()
    s.write(temp_buff, p7)
    x = temp_buff.read()
    return x
def encrypt_block ( blob , pubkey ) : # Make a MemoryBuffer of the message. inbuf = BIO . MemoryBuffer ( blob ) # Seed the PRNG. Rand . rand_seed ( os . urandom ( 1024 ) ) # Instantiate an SMIME object. s = SMIME . SMIME ( ) # Load target cert to encrypt to. x509 = X509 . load_cert ( pubkey ) sk = X509 . X509_Stack ( ) sk . push ( x509 ) s . set_x509_stack ( sk ) # Set cipher: AES 256 bit in CBC mode. s . set_cipher ( SMIME . Cipher ( 'aes_256_cbc' ) ) # Encrypt the buffer. p7 = s . encrypt ( inbuf ) temp_buff = BIO . MemoryBuffer ( ) s . write ( temp_buff , p7 ) x = temp_buff . read ( ) return x