/
Example.groovy
49 lines (39 loc) · 1.4 KB
/
Example.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@GrabResolver(name='jitpack', root='https://jitpack.io/')
@Grab('com.github.micheal-swiggs:jumblar:v0.2.1')
@GrabExclude('org.codehaus.groovy:groovy-all')
/**
* Run with :
* groovy Example.groovy
*/
import com.jumblar.core.domain.SimpleJumble;
import com.jumblar.core.controllers.BaseController;
import com.jumblar.core.controllers.PhraseController;
println "Welcome to the Jumblar"
String username = "your-username";
String email = "your-addy@special.domain";
String personalInfo = "";
String password = "password";
String coordinate = "48.858404,2.293571"; //Corner of eiffel tower.
int N = 1024;
int r = 8;
int p = 1;
int keyLength = 64;
BaseController bc = new BaseController();
/**
* Upload new user info to PGP servers.
*/
SimpleJumble originalJumble = bc.createNewPGPEntry(username, email, personalInfo, password, coordinate,
N, r, p, keyLength);
byte[] original = originalJumble.getHashBase().getHashBase()
/**
* Simulates a user signing in.
*/
String guessCoordinate = "48.858405,2.293577";
SimpleJumble guessJumble = bc.computeHashBase(username, email, personalInfo, password, guessCoordinate);
byte[] guess = guessJumble.getHashBase().getHashBase()
/**
* This will only be true when uploading the first time.
*/
println Arrays.equals(original, guess)
def gmailPassword = PhraseController.generatePhrase(guessJumble.getHashBase(), "myemail@gmail.com", 5)
println "gmail-password: ${gmailPassword}"