Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1938-1966 (lines=29) @@
1935
1936
        // Now perform action on the file
1937
        $err = '';
1938
        if ($type === 'decrypt') {
1939
            try {
1940
                \Defuse\Crypto\File::decryptFile(
1941
                    $source_file,
1942
                    $target_file,
1943
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1944
                );
1945
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1946
                $err = "decryption_not_possible";
1947
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1948
                $err = $ex;
1949
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1950
                $err = $ex;
1951
            }
1952
        } elseif ($type === 'encrypt') {
1953
            try {
1954
                \Defuse\Crypto\File::encryptFile(
1955
                    $source_file,
1956
                    $target_file,
1957
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1958
                );
1959
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1960
                $err = "encryption_not_possible";
1961
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1962
                $err = $ex;
1963
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1964
                $err = $ex;
1965
            }
1966
        }
1967
    } else {
1968
    /*
1969
    File encryption/decryption is done with special password and not the SALTKEY
@@ 1973-2001 (lines=29) @@
1970
     */
1971
1972
        $err = '';
1973
        if ($type === 'decrypt') {
1974
            try {
1975
                \Defuse\Crypto\File::decryptFileWithPassword(
1976
                    $source_file,
1977
                    $target_file,
1978
                    $password
1979
                );
1980
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1981
                $err = "wrong_key";
1982
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1983
                $err = $ex;
1984
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1985
                $err = $ex;
1986
            }
1987
        } elseif ($type === 'encrypt') {
1988
            try {
1989
                \Defuse\Crypto\File::encryptFileWithPassword(
1990
                    $source_file,
1991
                    $target_file,
1992
                    $password
1993
                );
1994
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1995
                $err = "wrong_key";
1996
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1997
                $err = $ex;
1998
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1999
                $err = $ex;
2000
            }
2001
        }
2002
    }
2003
2004
    // return error