Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package freenet.tools;
- import static freenet.keys.InsertableClientSSK.createRandom;
- import static java.lang.String.format;
- import static java.lang.System.currentTimeMillis;
- import static java.util.concurrent.TimeUnit.MILLISECONDS;
- import freenet.crypt.RandomSource;
- import freenet.crypt.Yarrow;
- import freenet.keys.InsertableClientSSK;
- /**
- * Generates a vanity key pair, i.e. a keypair with the public key starting
- * with a specific set of characters.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
- public class GenerateVanityKey {
- public static void main(String... arguments) throws Exception {
- RandomSource randomSource = new Yarrow();
- long firstOutput = currentTimeMillis();
- long lastOutput = firstOutput;
- long generatedKeys = 0;
- long foundKeys = 0;
- String prefixToSearch = (arguments.length > 0) ? arguments[0].toLowerCase() : "free";
- while (true) {
- InsertableClientSSK clientSSK = createRandom(randomSource, "");
- generatedKeys++;
- if (clientSSK.getURI().toString().toLowerCase().substring(4).startsWith(prefixToSearch)) {
- System.err.println(format("\r%s <- %s", clientSSK.getURI(),
- clientSSK.getInsertURI()));
- foundKeys++;
- }
- long currentTime = currentTimeMillis();
- if ((currentTime - lastOutput) > 1000) {
- long timeSpent = currentTime - firstOutput;
- System.out.print(format("\r%d/s, %.3f/s",
- generatedKeys / MILLISECONDS.toSeconds(timeSpent),
- (double) foundKeys / MILLISECONDS.toSeconds(timeSpent)));
- lastOutput = currentTime;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement