How are you testing to compare $encode() with OpenSSL?

Also, are you saying that there is an issue with $decode() ie. that it is not decoding to the original $encode()ed text correctly?