Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1837-1865 (lines=29) @@
1834
1835
        // Now perform action on the file
1836
        $err = '';
1837
        if ($type === 'decrypt') {
1838
            try {
1839
                \Defuse\Crypto\File::decryptFile(
1840
                    $source_file,
1841
                    $target_file,
1842
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1843
                );
1844
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1845
                $err = "decryption_not_possible";
1846
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1847
                $err = $ex;
1848
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1849
                $err = $ex;
1850
            }
1851
        } elseif ($type === 'encrypt') {
1852
            try {
1853
                \Defuse\Crypto\File::encryptFile(
1854
                    $source_file,
1855
                    $target_file,
1856
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1857
                );
1858
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1859
                $err = "encryption_not_possible";
1860
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1861
                $err = $ex;
1862
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1863
                $err = $ex;
1864
            }
1865
        }
1866
    } else {
1867
        /*
1868
        File encryption/decryption is done with special password and not the SALTKEY
@@ 1872-1900 (lines=29) @@
1869
         */
1870
1871
        $err = '';
1872
        if ($type === 'decrypt') {
1873
            try {
1874
                \Defuse\Crypto\File::decryptFileWithPassword(
1875
                    $source_file,
1876
                    $target_file,
1877
                    $password
1878
                );
1879
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1880
                $err = "wrong_key";
1881
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1882
                $err = $ex;
1883
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1884
                $err = $ex;
1885
            }
1886
        } elseif ($type === 'encrypt') {
1887
            try {
1888
                \Defuse\Crypto\File::encryptFileWithPassword(
1889
                    $source_file,
1890
                    $target_file,
1891
                    $password
1892
                );
1893
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1894
                $err = "wrong_key";
1895
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1896
                $err = $ex;
1897
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1898
                $err = $ex;
1899
            }
1900
        }
1901
    }
1902
1903
    // return error