Get the App
SLTechnology News&Howtos  ›  Development  › 

How to customize desensitization rules by SharedingSphere

Shulou Source: shulou.com Published: 2022-06-02 06:12:16 10月02日 Update

This article mainly introduces SharedingSphere how to customize the desensitization rules, the article is very detailed, has a certain reference value, interested friends must read it!

Official default desensitization

You can see that the Type used is the aes algorithm,

How do we implement our own custom rules. Implement interface org.apache.shardingsphere.encrypt.strategy.spi.Encryptor

two。 Modify yml configuration file

Here the encryption type is written as its own custom, which can be done at will.

Then add Type to your own implementation class.

Write init methods

Private final static String TYPE = "custom-aes"; private static final String SHARDING_PROPERTIES = "properties/sharding.properties"; private Properties properties; @ Override public void init () {try {properties = PropertiesLoaderUtils.loadAllProperties (SHARDING_PROPERTIES);} catch (IOException e) {log.error ("failed to read sharding configuration file," + e.getMessage (), e) Throw new RuntimeException ("failed to read sharding configuration file," + e.getMessage (), e);}}

We will implement the Properties get/set method after the initial completion.

Then comes the most important part, which is to customize the encryption and decryption rules.

Here, you can customize your own implementation.

By the way, the document also says ase.key.value, which we can define in the Properties file and read in.

This method is in our custom encrypted key.

Finally, we need to configure our custom package path to the automatic assembly path of springboot.

The above is all the content of this article "how to customize the desensitization rules of SharedingSphere". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: File rule configuration desensitization method content that is article path encryption important right next lieutenant general value interest official boy partner interface Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi Apple Docker Microsoft