数据加密

存储单元操作

  1. REGISTER STORAGE UNIT ds_0 (
  2. HOST="127.0.0.1",
  3. PORT=3306,
  4. DB="ds_0",
  5. USER="root",
  6. PASSWORD="root"
  7. );

规则操作

  • 创建加密规则
  1. CREATE ENCRYPT RULE t_encrypt (
  2. COLUMNS(
  3. (NAME=user_id,CIPHER=user_cipher,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc')))),
  4. (NAME=order_id,CIPHER =order_cipher,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc'))))
  5. ));
  • 创建加密表
  1. CREATE TABLE `t_encrypt` (
  2. `id` int(11) NOT NULL,
  3. `user_id` varchar(45) DEFAULT NULL,
  4. `order_id` varchar(45) DEFAULT NULL,
  5. PRIMARY KEY (`id`)
  6. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  • 修改加密规则
  1. ALTER ENCRYPT RULE t_encrypt (
  2. COLUMNS(
  3. (NAME=user_id,CIPHER=user_cipher,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc'))))
  4. ));
  • 删除加密规则
  1. DROP ENCRYPT RULE t_encrypt;
  • 移除数据源
  1. UNREGISTER STORAGE UNIT ds_0;
  • 删除分布式数据库
  1. DROP DATABASE encrypt_db;