RUBY-791 Introduce krypt for common behaviour between MRI and JRuby