Refactor crypto system