Encrypt

Resource Operation

  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. );

Rule Operation

  • Create encrypt rule
  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. ));
  • Create encrypt table
  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;
  • Alter encrypt rule
  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. ));
  • Drop encrypt rule
  1. DROP ENCRYPT RULE t_encrypt;
  • Drop resource
  1. DROP RESOURCE ds_0;
  • Drop distributed database
  1. DROP DATABASE encrypt_db;