public function decrypt($string, $encryption_key = null) { $string = (string) $string; $encryption_key = $encryption_key === null ? $this->key : (string) $encryption_key; $old_key_size = GibberishAES::size(); GibberishAES::size(256); $result = GibberishAES::dec($string, $encryption_key); GibberishAES::size($old_key_size); return $result; }
public function testEncryptionWith256BitKeySize() { GibberishAES::size(256); foreach ($this->examples as $example) { $encrypted = GibberishAES::enc($example, $this->passPhrase); $this->assertEquals($example, GibberishAES::dec($encrypted, $this->passPhrase)); } GibberishAES::size("256"); foreach ($this->examples as $example) { $encrypted = GibberishAES::enc($example, $this->passPhrase); $this->assertEquals($example, GibberishAES::dec($encrypted, $this->passPhrase)); } }
public function ajax_decryption_test() { $this->output->set_header('Content-Type: application/json; charset=utf-8', true); $pass = $this->pass; $encrypted_secret_string_256 = $this->input->post('encrypted_secret_string_256'); $encrypted_secret_string_192 = $this->input->post('encrypted_secret_string_192'); $encrypted_secret_string_128 = $this->input->post('encrypted_secret_string_128'); $old_key_size = GibberishAES::size(); GibberishAES::size(256); $decrypted_secret_string_256 = GibberishAES::dec($encrypted_secret_string_256, $pass); GibberishAES::size(192); $decrypted_secret_string_192 = GibberishAES::dec($encrypted_secret_string_192, $pass); GibberishAES::size(128); $decrypted_secret_string_128 = GibberishAES::dec($encrypted_secret_string_128, $pass); GibberishAES::size($old_key_size); $this->output->set_output(json_encode(compact('decrypted_secret_string_256', 'decrypted_secret_string_192', 'decrypted_secret_string_128'))); }
public static function dec($data, $key) { return GibberishAES::dec($data, $key); }