Refactor crypto/key