Encrypt

Storage unit Operation

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

Rule Operation

  • Create encrypt rule
  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. ));
  • 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,CIPHER=user_cipher,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc'))))
  4. ));
  • Drop encrypt rule
  1. DROP ENCRYPT RULE t_encrypt;
  • Unregister storage unit
  1. UNREGISTER STORAGE UNIT ds_0;
  • Drop distributed database
  1. DROP DATABASE encrypt_db;