StringVal EncryptionFunctions::to_base64(FunctionContext* ctx, const StringVal& src) {
    if (src.len == 0 || src.is_null) {
        return StringVal::null();
    }

    int encoded_len = (size_t)(4.0 * ceil((double)src.len / 3.0));
    std::unique_ptr<char[]> encoded_text;
    encoded_text.reset(new char[encoded_len]);

    int encoded_text_len =
            base64_encode((unsigned char*)src.ptr, src.len, (unsigned char*)encoded_text.get());
    if (encoded_text_len < 0) {
        return StringVal::null();
    }
    return AnyValUtil::from_buffer_temp(ctx, encoded_text.get(), encoded_text_len);
}
StringVal EncryptionFunctions::to_base64(FunctionContext* ctx, const StringVal& src) {
    if (src.len == 0 || src.is_null) {
        return StringVal::null();
    }

    int encoded_len = (size_t)(4.0 * ceil((double)src.len / 3.0));
    std::unique_ptr<char[]> encoded_text;
    encoded_text.reset(new char[encoded_len]);

    int encoded_text_len =
            base64_encode((unsigned char*)src.ptr, src.len, (unsigned char*)encoded_text.get());
    if (encoded_text_len < 0) {
        return StringVal::null();
    }
    return AnyValUtil::from_buffer_temp(ctx, encoded_text.get(), encoded_text_len);
}