Refactor crypto