Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

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