Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

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