All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taotao.boot.data.shardingsphere.algorithm.FirstNLastM Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2020-2030, Shuigedeng ([email protected] & https://blog.taotaocloud.top/).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.taotao.boot.data.shardingsphere.algorithm;

import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithmMetaData;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;

/**
 * @description 基于自定义加解密实现数据脱敏
 */
public class FirstNLastM implements EncryptAlgorithm {

	@Override
	public Object encrypt(Object o, AlgorithmSQLContext algorithmSQLContext) {
		return null;
	}

	@Override
	public Object decrypt(Object o, AlgorithmSQLContext algorithmSQLContext) {
		return null;
	}

	@Override
	public EncryptAlgorithmMetaData getMetaData() {
		return null;
	}

	// private Properties properties;
    //
    // private int firstN;
    //
    // private int lastM;
    //
    // private String replaceChar;
    //
    // @Override
    // public String encrypt(Object o, EncryptContext encryptContext) {
    //     if (null == o) {
    //         return null;
    //     }
    //     return o.toString();
    // }
    //
    // @Override
    // public Object decrypt(String s, EncryptContext encryptContext) {
    //     if (null == s || s.length() == 0) {
    //         return replaceChar;
    //     }
    //
    //     if (s.length() > (firstN + lastM)) {
    //         return (s.substring(0, firstN) + s.substring(firstN, s.length() - lastM).replaceAll(".", replaceChar) +
    // s.substring(s.length() - lastM));
    //     } else if (s.length() > 2) {
    //         return (s.substring(0, 1) + replaceChar + s.substring(s.length() - 1));
    //     } else {
    //         return replaceChar;
    //     }
    // }
    //
    // @Override
    // public Properties getProps() {
    //     return properties;
    // }
    //
    // @Override
    // public void init(Properties properties) {
    //     this.properties = properties;
    //     firstN = Integer.valueOf(this.properties.getProperty("first-n"));
    //     lastM = Integer.valueOf(this.properties.getProperty("last-m"));
    //     replaceChar = this.properties.getProperty("replace-char");
    // }
    //
    // @Override
    // public String getType() {
    //     return "First_N_Last_M";
    // }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy