Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

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