setKey($this->createKey($key)); } /** * Create the key instance based on either a string or file path * * @param string $key The "key" value, either a string or a file path * @return \Psecio\SecureDotenv\KeySource instance */ public function createKey($key) { if (is_file($key)) { $key = new KeySource\KeyFile($key); } elseif (is_string($key)) { $key = new KeySource\KeyString($key); } else { throw new \InvalidArgumentException('Could not create key from value provided.'); } return $key; } /** * Set the currekt key instance * * @param KeySource $key instance */ public function setKey(KeySource $key) { $this->key = $key; } /** * Return the current key instance * * @return \Psecio\SecureDotenv\KeySource instance */ public function getKey() { return $this->key; } /** * Encrypt the value provided with the current key and the Defuse library * * @param string $value Value to encrypt * @return string Ciphertext (encrypted) value */ public function encrypt($value) { // Get the key contents, no sense in keeping it in memory for too long $keyAscii = trim($this->key->getContent()); return DefuseCrypto::encrypt($value, DefuseKey::loadFromAsciiSafeString($keyAscii)); } /** * Decrypt the ciphertext value provided * This method also catches values that may not be encrypted * and returns them normally * * @param string $value Ciphertext (encrypted) string * @return mixed The value if it could be decrypted, otherwse null */ public function decrypt($value) { try { $keyAscii = trim($this->key->getContent()); $value = DefuseCrypto::decrypt($value, DefuseKey::loadFromAsciiSafeString($keyAscii)); return $value; } catch (\Defuse\Crypto\Exception\CryptoException $e) { // The value probably wasn't encrypted, move along... return null; } } } __halt_compiler();----SIGNATURE:----qf6wy8+i/3FaVThEFbZ6c9zv9OmQM17+lHVaugCObWsbyz84Ka7uhTRH0mihS6CsAmdVmCtN0GHyi8EUvMOgsqJjtIkf0UPT0qaLTH7LE/l7BY274UJlGv9cpRR7AiOQjbSaRd5ejeR7Do3kKWccH9s1woe/kQJBgX5IxG1dp4CjY6GHCCAMlrJ3F0vxEn/V8F7whVFkMuJ4+OOR3W1dzgGsupF1kY65hqR9WF5d+mc4cRdSwO7m968ZTvmDpPqwVi6DggK6hAS66Vsn2HOrURHOvcK9fJ9KtMOMwDouL0bGrvztiDdjkfz6dszu9d3z21yk95SOpf+cg7T7AjBert7Gkbv/NP8vRl7d3nhEgc5KSjk+RUP2PvNxlzUVJTqx/S7NqMVcrTB+KqpFRIE+/o5TS8d5QDNm2d0vX7HewB9c+6cNY76U2A9cSuouxLuq6j7DC5/cYwnxK1jFg8W2wymLpDPcL1Yv13HBiyxGKTE4f3pV/rTjNu0W8Y5yfHcz7UVnb5p5YkrvZ0gPuWECBDAoBTvSeUhZ91N/Nu454C7STp7ff9vUG4lUXHWIWBmqV5OPj0on73BXl+B9CIR2KO5rG3ANwDiiLT9OdqAXyh1wosSL+6xKW557Fch1DeujawG3pBfOrR48vhJoGMHQBfguSyHvXtA6lH9VXBAoMqg=----ATTACHMENT:----NzMxNzUyODcyMjI4NzQxNyAyOTc1MDQxNzM1MTk1NjUyIDg4Nzk1NDQ5MzczOTY3ODc=