| @@ 1801-1829 (lines=29) @@ | ||
| 1798 | ||
| 1799 | // Now perform action on the file |
|
| 1800 | $err = ''; |
|
| 1801 | if ($type === 'decrypt') { |
|
| 1802 | try { |
|
| 1803 | \Defuse\Crypto\File::decryptFile( |
|
| 1804 | $source_file, |
|
| 1805 | $target_file, |
|
| 1806 | \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key) |
|
| 1807 | ); |
|
| 1808 | } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) { |
|
| 1809 | $err = "decryption_not_possible"; |
|
| 1810 | } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) { |
|
| 1811 | $err = $ex; |
|
| 1812 | } catch (Defuse\Crypto\Exception\IOException $ex) { |
|
| 1813 | $err = $ex; |
|
| 1814 | } |
|
| 1815 | } else if ($type === 'encrypt') { |
|
| 1816 | try { |
|
| 1817 | \Defuse\Crypto\File::encryptFile( |
|
| 1818 | $source_file, |
|
| 1819 | $target_file, |
|
| 1820 | \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key) |
|
| 1821 | ); |
|
| 1822 | } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) { |
|
| 1823 | $err = "encryption_not_possible"; |
|
| 1824 | } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) { |
|
| 1825 | $err = $ex; |
|
| 1826 | } catch (Defuse\Crypto\Exception\IOException $ex) { |
|
| 1827 | $err = $ex; |
|
| 1828 | } |
|
| 1829 | } |
|
| 1830 | ||
| 1831 | } else { |
|
| 1832 | /* |
|
| @@ 1837-1865 (lines=29) @@ | ||
| 1834 | */ |
|
| 1835 | ||
| 1836 | $err = ''; |
|
| 1837 | if ($type === 'decrypt') { |
|
| 1838 | try { |
|
| 1839 | \Defuse\Crypto\File::decryptFileWithPassword( |
|
| 1840 | $source_file, |
|
| 1841 | $target_file, |
|
| 1842 | $password |
|
| 1843 | ); |
|
| 1844 | } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) { |
|
| 1845 | $err = "wrong_key"; |
|
| 1846 | } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) { |
|
| 1847 | $err = $ex; |
|
| 1848 | } catch (Defuse\Crypto\Exception\IOException $ex) { |
|
| 1849 | $err = $ex; |
|
| 1850 | } |
|
| 1851 | } else if ($type === 'encrypt') { |
|
| 1852 | try { |
|
| 1853 | \Defuse\Crypto\File::encryptFileWithPassword( |
|
| 1854 | $source_file, |
|
| 1855 | $target_file, |
|
| 1856 | $password |
|
| 1857 | ); |
|
| 1858 | } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) { |
|
| 1859 | $err = "wrong_key"; |
|
| 1860 | } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) { |
|
| 1861 | $err = $ex; |
|
| 1862 | } catch (Defuse\Crypto\Exception\IOException $ex) { |
|
| 1863 | $err = $ex; |
|
| 1864 | } |
|
| 1865 | } |
|
| 1866 | } |
|
| 1867 | ||
| 1868 | // return error |
|