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