Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1965-1993 (lines=29) @@
1962
1963
        // Now perform action on the file
1964
        $err = '';
1965
        if ($type === 'decrypt') {
1966
            try {
1967
                \Defuse\Crypto\File::decryptFile(
1968
                    $source_file,
1969
                    $target_file,
1970
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1971
                );
1972
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1973
                $err = "decryption_not_possible";
1974
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1975
                $err = $ex;
1976
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1977
                $err = $ex;
1978
            }
1979
        } elseif ($type === 'encrypt') {
1980
            try {
1981
                \Defuse\Crypto\File::encryptFile(
1982
                    $source_file,
1983
                    $target_file,
1984
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1985
                );
1986
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1987
                $err = "encryption_not_possible";
1988
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1989
                $err = $ex;
1990
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1991
                $err = $ex;
1992
            }
1993
        }
1994
    } else {
1995
    /*
1996
    File encryption/decryption is done with special password and not the SALTKEY
@@ 2000-2028 (lines=29) @@
1997
     */
1998
1999
        $err = '';
2000
        if ($type === 'decrypt') {
2001
            try {
2002
                \Defuse\Crypto\File::decryptFileWithPassword(
2003
                    $source_file,
2004
                    $target_file,
2005
                    $password
2006
                );
2007
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
2008
                $err = "wrong_key";
2009
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
2010
                $err = $ex;
2011
            } catch (Defuse\Crypto\Exception\IOException $ex) {
2012
                $err = $ex;
2013
            }
2014
        } elseif ($type === 'encrypt') {
2015
            try {
2016
                \Defuse\Crypto\File::encryptFileWithPassword(
2017
                    $source_file,
2018
                    $target_file,
2019
                    $password
2020
                );
2021
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
2022
                $err = "wrong_key";
2023
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
2024
                $err = $ex;
2025
            } catch (Defuse\Crypto\Exception\IOException $ex) {
2026
                $err = $ex;
2027
            }
2028
        }
2029
    }
2030
2031
    // return error