Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1915-1943 (lines=29) @@
1912
1913
        // Now perform action on the file
1914
        $err = '';
1915
        if ($type === 'decrypt') {
1916
            try {
1917
                \Defuse\Crypto\File::decryptFile(
1918
                    $source_file,
1919
                    $target_file,
1920
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1921
                );
1922
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1923
                $err = "decryption_not_possible";
1924
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1925
                $err = $ex;
1926
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1927
                $err = $ex;
1928
            }
1929
        } elseif ($type === 'encrypt') {
1930
            try {
1931
                \Defuse\Crypto\File::encryptFile(
1932
                    $source_file,
1933
                    $target_file,
1934
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1935
                );
1936
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1937
                $err = "encryption_not_possible";
1938
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1939
                $err = $ex;
1940
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1941
                $err = $ex;
1942
            }
1943
        }
1944
    } else {
1945
    /*
1946
    File encryption/decryption is done with special password and not the SALTKEY
@@ 1950-1978 (lines=29) @@
1947
     */
1948
1949
        $err = '';
1950
        if ($type === 'decrypt') {
1951
            try {
1952
                \Defuse\Crypto\File::decryptFileWithPassword(
1953
                    $source_file,
1954
                    $target_file,
1955
                    $password
1956
                );
1957
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1958
                $err = "wrong_key";
1959
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1960
                $err = $ex;
1961
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1962
                $err = $ex;
1963
            }
1964
        } elseif ($type === 'encrypt') {
1965
            try {
1966
                \Defuse\Crypto\File::encryptFileWithPassword(
1967
                    $source_file,
1968
                    $target_file,
1969
                    $password
1970
                );
1971
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1972
                $err = "wrong_key";
1973
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1974
                $err = $ex;
1975
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1976
                $err = $ex;
1977
            }
1978
        }
1979
    }
1980
1981
    // return error