@amasad/

test-1

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
  • Base58Check.java
  • Block.java
  • Bytes.java
  • FileUtil.java
  • Hash.java
  • Strings.java
  • TransactionOutput.java
Main.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.util.Scanner;
import java.math.BigInteger;
import java.io.IOException;

class Main {
  public static void main(String[] args) {
    try {
      FileUtil.genAllFiles();
    } catch (IOException ex) {
      System.out.println("Failed to generate files.");
    }
    
    /*
    clearScreen();
    Scanner scan = new Scanner(System.in);
    BigInteger g, p, a, A, B, S;
    System.out.print("Diffie-Hellman Key Exchange allows two parties\nto create a Shared Secret Key value with each other\nthrough a public channel, without disclosing their\nown Secret value used to create the Shared Secret Key.");
    pause(10000);
    clearScreen();
    System.out.println("Both you and the other party must disclose two\nShared values to agree on: g and p.");
    pause(8000);
    while(true) {
      System.out.print("\nInput the Shared value, g: ");
      String g_str = scan.nextLine();
      try {
        g = new BigInteger(g_str);
        break;
      } catch (Exception ex) {
        System.out.println("Invalid input. Only numbers allowed.");
      }
    }
    while(true) {
      System.out.print("Input the Shared value, p: ");
      String p_str = scan.nextLine();
      try {
        p = new BigInteger(p_str);
        break;
      } catch (Exception ex) {
        System.out.println("Invalid input. Only numbers allowed.");
      }
    }
    clearScreen();
    System.out.println("You must come up with a random number (can be very large)\nto be your Secret value. DO NOT DISCLOSE THIS SECRET VALUE.");
    pause(8000);
    while(true) {
      System.out.print("\nInput your Secret Key value, a: ");
      String a_str = scan.nextLine();
      try {
        a = new BigInteger(a_str);
        break;
      } catch (Exception ex) {
        System.out.println("Invalid input. Only numbers allowed.");
      }
    }
    A = g.modPow(a, p);
    System.out.println("\nYour Public Key value, A = " + A);
    pause(3000);
    System.out.println("\nShare your Public Key, A, with the other party.");
    pause(12000);
    clearScreen();
    System.out.println("The other party will do the same with their own Public Key, B.\n");
    pause(3000);
    while(true) {
      System.out.print("Input other party's Public Key, B: ");
      String B_str = scan.nextLine();
      try {
        B = new BigInteger(B_str);
        break;
      } catch (Exception ex) {
        System.out.println("Invalid input. Only numbers allowed.");
      }
    }
    clearScreen();
    S = B.modPow(a, p);
    System.out.println("Both you and the other party will now have\nthe same value as your Shared Secret Key, without\never sharing your own Secret value.\n");
    pause(4000);
    System.out.println("Your Shared Secret Key value, S = " + S);
    scan.close();
    */
  }

  public static void clearScreen() {  
    System.out.print("\033[H\033[2J");  
    System.out.flush();  
  }

  public static void pause(int milliseconds) {
    try {
      Thread.sleep(milliseconds);
    } catch (Exception ex) {}
  }
}