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