Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

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