EncryptRule implements ShardingSphereRule { public List<Object> getEncryptValues(final String logicTable, final String logicColumn, final List<Object> originalValues) { Optional<EncryptAlgorithm> encryptor = findEncryptor(logicTable, logicColumn); Preconditions.checkArgument(encryptor.isPresent(), String.format("Can not find QueryAssistedEncryptAlgorithm by %s.%s.", logicTable, logicColumn)); return originalValues.stream().map(input -> null == input ? null : String.valueOf(encryptor.get().encrypt(input.toString()))).collect(Collectors.toList()); } EncryptRule(final EncryptRuleConfiguration config);  EncryptRule(final AlgorithmProvidedEncryptRuleConfiguration config); Collection<String> getEncryptTableNames(); Optional<EncryptTable> findEncryptTable(final String logicTable); Optional<EncryptAlgorithm> findEncryptor(final String logicTable, final String logicColumn); List<Object> getEncryptValues(final String logicTable, final String logicColumn, final List<Object> originalValues); boolean isCipherColumn(final String tableName, final String columnName); String getCipherColumn(final String logicTable, final String logicColumn); String getLogicColumnOfCipher(final String logicTable, final String cipherColumn); Map<String, String> getLogicAndCipherColumns(final String logicTable); Optional<String> findAssistedQueryColumn(final String logicTable, final String logicColumn); Collection<String> getAssistedQueryColumns(final String logicTable); List<Object> getEncryptAssistedQueryValues(final String logicTable, final String logicColumn, final List<Object> originalValues); Collection<String> getAssistedQueryAndPlainColumns(final String logicTable); Optional<String> findPlainColumn(final String logicTable, final String logicColumn);  }
@Test public void assertGetEncryptValues() { List<Object> encryptAssistedQueryValues = new EncryptRule(createEncryptRuleConfiguration()).getEncryptValues("t_encrypt", "pwd", Collections.singletonList(null)); for (final Object value : encryptAssistedQueryValues) { assertNull(value); } }