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
9756f012
Commit
9756f012
authored
Dec 04, 2017
by
Pedro Cavaleiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented random pin generator, removed unecessary comments
parent
028da0bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
9 deletions
+118
-9
Helpers.java
FallIntoOblivion/src/fallintooblivion/Helpers.java
+11
-9
RandomString.java
FallIntoOblivion/src/fallintooblivion/RandomString.java
+107
-0
No files found.
FallIntoOblivion/src/fallintooblivion/Helpers.java
View file @
9756f012
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
fallintooblivion
;
package
fallintooblivion
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.security.SecureRandom
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -286,14 +282,20 @@ public class Helpers {
...
@@ -286,14 +282,20 @@ public class Helpers {
String
outFile
=
"Fall_Into_Oblivion/Trashed/"
+
fileName
+
"/"
+
fileName
;
String
outFile
=
"Fall_Into_Oblivion/Trashed/"
+
fileName
+
"/"
+
fileName
;
// TEMPORARY debugging purposes only
// 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
// 24 Byte or 32 Byte will say Invalid Key Size, even though it's a valid key size
// 24 Byte or 32 Byte will say Invalid Key Size, even though it's a valid key size
// TODO: Randomize 3 or 4 digit pin without printing it to the user
RandomString
pinGenerator
=
new
RandomString
(
4
,
new
SecureRandom
(),
RandomString
.
Symbols
.
digits
);
String
pinHASH
=
SHA256
.
calculateStringMAC
(
"0000"
);
String
genPin
=
pinGenerator
.
nextString
();
String
pinHASH
=
SHA256
.
calculateStringMAC
(
genPin
);
pinHASH
=
pinHASH
.
subSequence
(
0
,
16
).
toString
();
pinHASH
=
pinHASH
.
subSequence
(
0
,
16
).
toString
();
// System.out.println(genPin); // Uncomment this line to view the generated pin
// Uncomment the two lines below to generate the key to the pin 0000
// String pinHASH = SHA256.calculateStringMAC("0000");
// pinHASH = pinHASH.subSequence(0, 16).toString();
// Encrypt the file using the defined cypher type, it defaults to AES-CBC
// Encrypt the file using the defined cypher type, it defaults to AES-CBC
switch
(
cypher
)
{
switch
(
cypher
)
{
case
"aes_cbc"
:
case
"aes_cbc"
:
...
...
FallIntoOblivion/src/fallintooblivion/RandomString.java
0 → 100644
View file @
9756f012
package
fallintooblivion
;
import
java.security.SecureRandom
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.Random
;
public
class
RandomString
{
/**
* Generate a random string.
*/
public
String
nextString
()
{
for
(
int
idx
=
0
;
idx
<
buf
.
length
;
++
idx
)
buf
[
idx
]
=
symbols
[
random
.
nextInt
(
symbols
.
length
)];
return
new
String
(
buf
);
}
public
enum
Symbols
{
uppercase
,
lowercase
,
digits
,
alphanumeric
,
upperlowercase
}
public
static
final
String
upper
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
final
String
lower
=
upper
.
toLowerCase
(
Locale
.
ROOT
);
public
static
final
String
digits
=
"0123456789"
;
public
static
final
String
alphanum
=
upper
+
lower
+
digits
;
private
final
Random
random
;
private
final
char
[]
symbols
;
private
final
char
[]
buf
;
public
RandomString
(
int
length
,
Random
random
,
String
symbols
)
{
if
(
length
<
1
)
throw
new
IllegalArgumentException
();
if
(
symbols
.
length
()
<
2
)
throw
new
IllegalArgumentException
();
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
symbols
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
}
public
RandomString
(
int
length
,
Random
random
,
Symbols
symbols
)
{
switch
(
symbols
)
{
case
digits:
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
digits
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
case
lowercase:
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
lower
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
case
uppercase:
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
upper
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
case
alphanumeric:
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
alphanum
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
case
upperlowercase:
String
alphabet
=
upper
+
lower
;
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
alphabet
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
default
:
this
.
random
=
Objects
.
requireNonNull
(
random
);
this
.
symbols
=
alphanum
.
toCharArray
();
this
.
buf
=
new
char
[
length
];
break
;
}
}
/**
* Create an alphanumeric string generator.
*/
public
RandomString
(
int
length
,
Random
random
)
{
this
(
length
,
random
,
alphanum
);
}
/**
* Create an alphanumeric strings from a secure generator.
*/
public
RandomString
(
int
length
)
{
this
(
length
,
new
SecureRandom
());
}
/**
* Create session identifiers.
*/
public
RandomString
()
{
this
(
21
);
}
}
\ No newline at end of file
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