factor the framework of crypto codec