Skip to content

Commit

Permalink
Filesystem safe base64 encode/decode
Browse files Browse the repository at this point in the history
  • Loading branch information
joostfaassen committed May 14, 2016
1 parent c6bb336 commit ea5e487
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Vault.php
Expand Up @@ -60,12 +60,23 @@ public function setWorkPath($workPath)

public function encryptFilename($filename)
{
return trim(base64_encode($this->encrypt($filename)), '=');
return trim($this->safeBase64Encode($this->encrypt($filename)), '=');
}

public function decryptFilename($filename)
{
return $this->decrypt(base64_decode($filename));
return $this->decrypt($this->safeBase64Decode($filename));
}

public function safeBase64Encode($input)
{
$input = trim($input, '=');
return strtr(base64_encode($input), '+/', '-_');
}

public function safeBase64Decode($input)
{
return base64_decode(strtr($input, '-_', '+/'));
}

public function encrypt($data)
Expand Down

0 comments on commit ea5e487

Please sign in to comment.