From e43b62d14c3a5c9a84656202df72187febc65d6d Mon Sep 17 00:00:00 2001 From: Emman Lijesta Date: Sun, 13 Jun 2021 21:52:19 +0800 Subject: [PATCH] Update vcrypt.php --- vcrypt.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vcrypt.php b/vcrypt.php index fc84d9e..61d0d80 100644 --- a/vcrypt.php +++ b/vcrypt.php @@ -8,7 +8,7 @@ class Vcrypt { # change the default k or key with a 64-char Hex, DO NOT change this key once in production - function __construct( $t, $k = "f0971dbfe2ca3c75b4dac60f087670f2caa19781057abb432a24daee6c915e93" ) { + function __construct( $t, $k ) { $this->t = $t; $this->k = $k; $this->l = strlen($k); @@ -24,13 +24,15 @@ protected function ver() { } function enc() { - # sanitizes input text, compress and encrypt using Vernam cipher - $this->t = gzdeflate(htmlspecialchars(stripslashes(trim($this->t))), 9); - return $this->ver(); + # sanitizes input text, convert to UTF-8, compress and encrypt using Vernam cipher + $this->t = htmlspecialchars(stripslashes(trim($this->t))); + $this->t = gzdeflate( $this->t, 9); + return utf8_encode($this->ver()); } function dec() { # decrypt the data and uncompress it + $this->t = utf8_decode($this->t); $this->t = $this->ver(); return gzinflate($this->t); }