Skip to content

Commit

Permalink
Update vcrypt.php
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanLijesta authored Jun 13, 2021
1 parent bf313d8 commit e43b62d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit e43b62d

Please sign in to comment.