Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FallIntoOblivion
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro Cavaleiro
FallIntoOblivion
Commits
7e6bef7c
Commit
7e6bef7c
authored
Dec 04, 2017
by
Pedro Cavaleiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the saving of encrypted files into the .cfg file, it now scans the…
Removed the saving of encrypted files into the .cfg file, it now scans the Trashed folder. Code optimization
parent
845b38d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
24 deletions
+17
-24
FallIntoOblivion.java
FallIntoOblivion/src/fallintooblivion/FallIntoOblivion.java
+15
-19
Helpers.java
FallIntoOblivion/src/fallintooblivion/Helpers.java
+2
-5
No files found.
FallIntoOblivion/src/fallintooblivion/FallIntoOblivion.java
View file @
7e6bef7c
package
fallintooblivion
;
package
fallintooblivion
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -15,8 +17,6 @@ public class FallIntoOblivion {
...
@@ -15,8 +17,6 @@ public class FallIntoOblivion {
private
static
final
String
setCypherInvalidKeySizeErr
=
" [keysize] \nInsert a valid number for parameter [keysize]\n"
;
private
static
final
String
setCypherInvalidKeySizeErr
=
" [keysize] \nInsert a valid number for parameter [keysize]\n"
;
private
static
final
String
setCypherIncalidKeyErr
=
" \nInsert a valid positive number for parameter [keysize]\n"
;
private
static
final
String
setCypherIncalidKeyErr
=
" \nInsert a valid positive number for parameter [keysize]\n"
;
public
static
ArrayList
encryptedFolders
=
new
ArrayList
<
String
>();
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
...
@@ -29,15 +29,6 @@ public class FallIntoOblivion {
...
@@ -29,15 +29,6 @@ public class FallIntoOblivion {
conf
.
saveProp
(
"hashtype"
,
"sha256"
);
conf
.
saveProp
(
"hashtype"
,
"sha256"
);
conf
.
saveProp
(
"keysize"
,
"16"
);
conf
.
saveProp
(
"keysize"
,
"16"
);
conf
.
saveProp
(
"cyphertype"
,
"aes_cbc"
);
conf
.
saveProp
(
"cyphertype"
,
"aes_cbc"
);
conf
.
saveProp
(
"encrypted"
,
""
);
}
// Get all the encrypted files/folders
if
(!
conf
.
getProp
(
"encrypted"
).
equals
(
""
)){
String
temp
[]
=
conf
.
getProp
(
"encrypted"
).
split
(
","
);
for
(
int
i
=
0
;
i
<
temp
.
length
;
i
++){
encryptedFolders
.
add
(
temp
[
i
]);
}
}
}
...
@@ -130,8 +121,9 @@ public class FallIntoOblivion {
...
@@ -130,8 +121,9 @@ public class FallIntoOblivion {
// 2. If it's a folder we zip it and delete the folder keeping the zip file
// 2. If it's a folder we zip it and delete the folder keeping the zip file
// 3. Sign the file and save a Public Key and Signature in the same folder then the encrypted file will be
// 3. Sign the file and save a Public Key and Signature in the same folder then the encrypted file will be
// 4. Encrypt the file
// 4. Encrypt the file
// 5. Move the file to the Trashed folder
// 5. Generate the hash of the encrypted file and save it along with the file
// 6. Delete the unencrypted file
// 6. Move the file to the Trashed folder
// 7. Delete the unencrypted file
WatchDir
.
foldersToEncryptLock
.
lock
();
WatchDir
.
foldersToEncryptLock
.
lock
();
try
{
try
{
File
file
;
File
file
;
...
@@ -168,9 +160,6 @@ public class FallIntoOblivion {
...
@@ -168,9 +160,6 @@ public class FallIntoOblivion {
// Encrypt the file
// Encrypt the file
Helpers
.
Encryptor
.
Encrypt
(
file
.
getName
(),
file
.
getAbsolutePath
(),
cyphertype
,
hashtype
);
Helpers
.
Encryptor
.
Encrypt
(
file
.
getName
(),
file
.
getAbsolutePath
(),
cyphertype
,
hashtype
);
// The file was successfully encrypted, we add it to the encrypted list
encryptedFolders
.
add
(
folder
.
toString
());
// Delete the unencrypted file
// Delete the unencrypted file
file
.
delete
();
file
.
delete
();
...
@@ -243,7 +232,16 @@ public class FallIntoOblivion {
...
@@ -243,7 +232,16 @@ public class FallIntoOblivion {
Helpers
.
CommandsHelper
.
translateToRestoreFileOption
(
words
[
1
]);
Helpers
.
CommandsHelper
.
translateToRestoreFileOption
(
words
[
1
]);
switch
(
option
)
{
switch
(
option
)
{
case
listfiles:
case
listfiles:
System
.
out
.
println
(
listToString
(
retreiveFileName
(
encryptedFolders
)).
replaceAll
(
","
,
"\n"
));
File
file
=
new
File
(
"Fall_Into_Oblivion/Trashed"
);
String
[]
directories
=
file
.
list
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
current
,
String
name
)
{
return
new
File
(
current
,
name
).
isDirectory
();
}
});
for
(
int
i
=
0
;
i
<
directories
.
length
;
i
++)
{
System
.
out
.
println
(
directories
[
i
]);
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
break
;
break
;
case
decryptfile:
case
decryptfile:
...
@@ -374,8 +372,6 @@ public class FallIntoOblivion {
...
@@ -374,8 +372,6 @@ public class FallIntoOblivion {
break
;
break
;
case
exit:
case
exit:
System
.
out
.
println
(
listToString
(
encryptedFolders
));
conf
.
saveProp
(
"encrypted"
,
listToString
(
encryptedFolders
));
System
.
exit
(
0
);
System
.
exit
(
0
);
default
:
default
:
...
...
FallIntoOblivion/src/fallintooblivion/Helpers.java
View file @
7e6bef7c
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
*/
*/
package
fallintooblivion
;
package
fallintooblivion
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -22,7 +21,7 @@ public class Helpers {
...
@@ -22,7 +21,7 @@ public class Helpers {
* @param directory diretório a ser apagado
* @param directory diretório a ser apagado
* @return verdadeiro se foi apagado caso contrario falso
* @return verdadeiro se foi apagado caso contrario falso
*/
*/
public
static
boolean
deleteDirectory
(
File
directory
)
{
public
static
void
deleteDirectory
(
File
directory
)
{
if
(
directory
.
exists
()){
if
(
directory
.
exists
()){
File
[]
files
=
directory
.
listFiles
();
File
[]
files
=
directory
.
listFiles
();
if
(
null
!=
files
){
if
(
null
!=
files
){
...
@@ -36,7 +35,7 @@ public class Helpers {
...
@@ -36,7 +35,7 @@ public class Helpers {
}
}
}
}
}
}
return
(
directory
.
delete
()
);
directory
.
delete
(
);
}
}
/**
/**
...
@@ -216,8 +215,6 @@ public class Helpers {
...
@@ -216,8 +215,6 @@ public class Helpers {
String
outFile
=
"Fall_Into_Oblivion/Trashed/"
+
fileName
+
"/"
+
fileName
;
String
outFile
=
"Fall_Into_Oblivion/Trashed/"
+
fileName
+
"/"
+
fileName
;
Assinatura
fileSigning
=
new
Assinatura
();
// TEMPORARY debugging purposes only
// TEMPORARY debugging purposes only
// Create the hash of the pin 0000
// Create the hash of the pin 0000
// So far we were only able to use 16 Byte key
// So far we were only able to use 16 Byte key
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment