I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 074c630a authored by zzz's avatar zzz
Browse files

Utils: Add RKG command line tool

parent f902a631
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ import net.i2p.crypto.SHA256Generator; ...@@ -22,6 +22,7 @@ import net.i2p.crypto.SHA256Generator;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.data.RoutingKeyGenerator; import net.i2p.data.RoutingKeyGenerator;
import net.i2p.util.ConvertToHash;
import net.i2p.util.HexDump; import net.i2p.util.HexDump;
import net.i2p.util.Log; import net.i2p.util.Log;
...@@ -216,23 +217,30 @@ public class RouterKeyGenerator extends RoutingKeyGenerator { ...@@ -216,23 +217,30 @@ public class RouterKeyGenerator extends RoutingKeyGenerator {
return SHA256Generator.getInstance().calculateHash(modVal); return SHA256Generator.getInstance().calculateHash(modVal);
} }
/**** /**
* @since 0.9.29
*/
public static void main(String args[]) { public static void main(String args[]) {
Hash k1 = new Hash(); if (args.length <= 0) {
byte k1d[] = new byte[Hash.HASH_LENGTH]; System.err.println("Usage: RouterKeyGenerator [-days] [+days] hash|hostname|destination");
RandomSource.getInstance().nextBytes(k1d); System.exit(1);
k1.setData(k1d); }
long now = System.currentTimeMillis();
for (int i = 0; i < 10; i++) { Hash h;
System.out.println("K1: " + k1); if (args.length > 1 && (args[0].startsWith("+") || args[0].startsWith("-"))) {
Hash k1m = RoutingKeyGenerator.getInstance().getRoutingKey(k1); now += Integer.parseInt(args[0]) * 24*60*60*1000L;
System.out.println("MOD: " + new String(RoutingKeyGenerator.getInstance().getModData())); h = ConvertToHash.getHash(args[1]);
System.out.println("K1M: " + k1m); } else {
h = ConvertToHash.getHash(args[0]);
} }
try { if (h == null) {
Thread.sleep(2000); System.err.println("Bad hash");
} catch (Throwable t) { // nop System.exit(1);
} }
RouterKeyGenerator rkg = new RouterKeyGenerator(I2PAppContext.getGlobalContext());
Hash rkey = rkg.getRoutingKey(h, now);
System.out.println("Date: " + rkg._fmt.format(now));
System.out.println("Original key: " + h.toBase64());
System.out.println("Routing key: " + rkey.toBase64());
} }
****/
} }
...@@ -15,6 +15,7 @@ public class CommandLine extends net.i2p.util.CommandLine { ...@@ -15,6 +15,7 @@ public class CommandLine extends net.i2p.util.CommandLine {
protected static final List<String> RCLASSES = Arrays.asList(new String[] { protected static final List<String> RCLASSES = Arrays.asList(new String[] {
"net.i2p.data.router.RouterInfo", "net.i2p.data.router.RouterInfo",
"net.i2p.data.router.RouterKeyGenerator",
"net.i2p.router.MultiRouter", "net.i2p.router.MultiRouter",
"net.i2p.router.Router", "net.i2p.router.Router",
"net.i2p.router.RouterLaunch", "net.i2p.router.RouterLaunch",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment