auto generate encode code