Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1886-1914 (lines=29) @@
1883
1884
        // Now perform action on the file
1885
        $err = '';
1886
        if ($type === 'decrypt') {
1887
            try {
1888
                \Defuse\Crypto\File::decryptFile(
1889
                    $source_file,
1890
                    $target_file,
1891
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1892
                );
1893
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1894
                $err = "decryption_not_possible";
1895
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1896
                $err = $ex;
1897
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1898
                $err = $ex;
1899
            }
1900
        } elseif ($type === 'encrypt') {
1901
            try {
1902
                \Defuse\Crypto\File::encryptFile(
1903
                    $source_file,
1904
                    $target_file,
1905
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1906
                );
1907
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1908
                $err = "encryption_not_possible";
1909
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1910
                $err = $ex;
1911
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1912
                $err = $ex;
1913
            }
1914
        }
1915
    } else {
1916
    /*
1917
    File encryption/decryption is done with special password and not the SALTKEY
@@ 1921-1949 (lines=29) @@
1918
     */
1919
1920
        $err = '';
1921
        if ($type === 'decrypt') {
1922
            try {
1923
                \Defuse\Crypto\File::decryptFileWithPassword(
1924
                    $source_file,
1925
                    $target_file,
1926
                    $password
1927
                );
1928
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1929
                $err = "wrong_key";
1930
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1931
                $err = $ex;
1932
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1933
                $err = $ex;
1934
            }
1935
        } elseif ($type === 'encrypt') {
1936
            try {
1937
                \Defuse\Crypto\File::encryptFileWithPassword(
1938
                    $source_file,
1939
                    $target_file,
1940
                    $password
1941
                );
1942
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1943
                $err = "wrong_key";
1944
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1945
                $err = $ex;
1946
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1947
                $err = $ex;
1948
            }
1949
        }
1950
    }
1951
1952
    // return error