DELIMITER $
DROP FUNCTION IF EXISTS Decrypt_char $
CREATE FUNCTION Decrypt_char(Varstring varchar(255)) RETURNS varchar(255)
BEGIN
DECLARE v_length INT DEFAULT 0;
DECLARE v_Tmp varchar(255) default '';
DECLARE v_Tmp2 char(1) default '';
set v_length=CHAR_LENGTH(Varstring);
WHILE v_length > 0 DO
set v_Tmp2 = mid(Varstring,v_length,1);
IF (ORD(v_Tmp2)> 130) THEN
set v_Tmp = concat(v_Tmp, char(ORD(CONVERT(v_Tmp2 USING ucs2)) -2 USING ucs2));
ELSE
set v_Tmp = concat(v_Tmp,v_Tmp2);
END IF;
SET v_length = v_length - 1;
END WHILE;
RETURN REVERSE(v_Tmp);
END $


DELIMITER $
DROP FUNCTION IF EXISTS Encrypt_char $
CREATE FUNCTION Encrypt_char(Varstring varchar(255)) RETURNS varchar(255)
BEGIN
DECLARE v_length INT DEFAULT 0;
DECLARE v_Tmp varchar(255) default '';
DECLARE v_Tmp2 char(1) default '';
set v_length=CHAR_LENGTH(Varstring);
WHILE v_length > 0 DO
set v_Tmp2 = mid(Varstring,v_length,1);
IF (ORD(v_Tmp2)> 128) THEN
set v_Tmp = concat(v_Tmp, char(ORD(CONVERT(v_Tmp2 USING ucs2)) +2 USING ucs2));
ELSE
set v_Tmp = concat(v_Tmp,v_Tmp2);
END IF;
SET v_length = v_length - 1;
END WHILE;
RETURN REVERSE(v_Tmp);
END $
