public static byte[] encode(String pText, String pKey) {
byte[] txt = pText.getBytes();
byte[] key = pKey.getBytes();
byte[] res = new byte[pText.length()];
for (int i = 0; i < txt.length; i++) {
res[i] = (byte) (txt[i] ^ key[i % key.length]);
}
return res;
}
public static String decode(byte[] pText, String pKey) {
byte[] res = new byte[pText.length];
byte[] key = pKey.getBytes();
for (int i = 0; i < pText.length; i++) {
res[i] = (byte) (pText[i] ^ key[i % key.length]);
}
return new String(res);
}
[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci'
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[client]
default-character-set = utf8mb4
+--------------------------+--------------------+
| Variable_name | Value |
+------------------------------+------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+-----------------------------+------------------------+
10 rows in set (0.01 sec)