数据加密

资源操作

  1. ADD RESOURCE 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,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),
  4. (NAME=order_id,PLAIN=order_plain,CIPHER =order_cipher,TYPE(NAME=RC4,PROPERTIES('rc4-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,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),
  4. ));
  • 删除加密规则
  1. DROP ENCRYPT RULE t_encrypt;
  • 删除数据源
  1. DROP RESOURCE ds_0;
  • 删除分布式数据库
  1. DROP DATABASE encrypt_db;