Read BLOB to string in PHP (Symfony2)

I have a MYSQL DB where I store encrypted credentials for an IMAP account.
The field for the password is a BLOB as recommended.

        $encrypter = new TripleDES(CRYPT_DES_MODE_ECB);
        $encrytped_pw = $encrypter->encrypt("MYPASSWORD");


Unfortunately I am not able to decrypt this field with this:

    $mailboxPw = $this->getUser()->getMailbox()->getPassword();

    $decrypter = new TripleDES(CRYPT_DES_MODE_ECB);
    $decrytped_pw = $decrypter->decrypt(base64_encode($mailboxPw));

as it gives me

Warning: base64_encode() expects parameter 1 to be string, resource given

I cannot find a way to convert a blob resource to string, is there anotther way to achieve what I want?

Any hint appreciated

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.