Refactors cipher logic into helper class

Refactor a bit of logic into a helper class to
make way to add a new API.

Test Plan:
Both integration and unit tests pass.
Merge pull request #14 from facebook/add_new_api

Refactors cipher logic into helper class