From 3aeba6c8f25892d235566488873831575c259fa9 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Wed, 25 Apr 2018 18:23:03 +0200 Subject: [PATCH] Better Server Memory Management & Programs can enque precompiled code --- .../src/de/mrbesen/CryptCrack.java | 68 +++++++++++++----- BBEncryptionCracker/test/CrackJOBID.class | Bin 0 -> 1308 bytes .../src/Comunication/Client.java | 7 +- .../src/Comunication/Server.java | 10 +-- Server/BesenBoincServer/src/Core/Program.java | 39 +++++++++- Server/BesenBoincServer/src/Core/Starter.java | 2 +- .../BesenBoincServer/src/Job/JobManager.java | 53 ++++++++++---- test-factorial/BBTestprogram/src/Test.java | 12 ++-- .../src/mrbesen/PrimeFinder.java | 22 +++--- 9 files changed, 156 insertions(+), 57 deletions(-) create mode 100644 BBEncryptionCracker/test/CrackJOBID.class diff --git a/BBEncryptionCracker/src/de/mrbesen/CryptCrack.java b/BBEncryptionCracker/src/de/mrbesen/CryptCrack.java index 781ade3..a8e0f5b 100644 --- a/BBEncryptionCracker/src/de/mrbesen/CryptCrack.java +++ b/BBEncryptionCracker/src/de/mrbesen/CryptCrack.java @@ -8,32 +8,62 @@ import Job.Result.PartialResult; public class CryptCrack extends Program { -// long public_key = 12600;//valid private key = 5042 -// long mod = 151621; -// long public_key = 14012539;//valid private key: 2597832237 -// long mod = 4862802614L; + // long public_key = 12600;//valid private key = 5042 + // long mod = 151621; + // long public_key = 14012539;//valid private key: 2597832237 + // long mod = 4862802614L; long public_key = 14742154580182L; //valid private key: 63409970811835 long mod = 7458897482494455378L; - int testsperrun = 50000000; + int testsperrun = 50000; + + private int i = 0; + + + //command to create a byte array from a file: xxd -p file | tr -d '\n' | sed 's/../&,(byte) 0x/g;s/,(byte) 0x$//' + private final static byte[] precompiledcode = {(byte) 0xca,(byte) 0xfe,(byte) 0xba,(byte) 0xbe,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x34,(byte) 0x00,(byte) 0x59,(byte) 0x0a,(byte) 0x00,(byte) 0x1e,(byte) 0x00,(byte) 0x31,(byte) 0x05,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0xaa,(byte) 0xbb,(byte) 0x09,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x32,(byte) 0x05,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0xee,(byte) 0xfe,(byte) 0x09,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x33,(byte) 0x05,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0xca,(byte) 0xca,(byte) 0x09,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x34,(byte) 0x05,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0xcc,(byte) 0xca,(byte) 0x09,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x35,(byte) 0x07,(byte) 0x00,(byte) 0x36,(byte) 0x03,(byte) 0x00,(byte) 0x00,(byte) 0xbb,(byte) 0xcc,(byte) 0x0a,(byte) 0x00,(byte) 0x0e,(byte) 0x00,(byte) 0x37,(byte) 0x07,(byte) 0x00,(byte) 0x38,(byte) 0x0a,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x39,(byte) 0x07,(byte) 0x00,(byte) 0x3a,(byte) 0x0a,(byte) 0x00,(byte) 0x3d,(byte) 0x00,(byte) 0x3e,(byte) 0x09,(byte) 0x00,(byte) 0x3f,(byte) 0x00,(byte) 0x40,(byte) 0x07,(byte) 0x00,(byte) 0x41,(byte) 0x0a,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x31,(byte) 0x0a,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x42,(byte) 0x08,(byte) 0x00,(byte) 0x43,(byte) 0x0a,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x44,(byte) 0x0a,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x45,(byte) 0x0a,(byte) 0x00,(byte) 0x13,(byte) 0x00,(byte) 0x46,(byte) 0x0a,(byte) 0x00,(byte) 0x0e,(byte) 0x00,(byte) 0x47,(byte) 0x07,(byte) 0x00,(byte) 0x48,(byte) 0x01,(byte) 0x00,(byte) 0x05,(byte) 0x73,(byte) 0x74,(byte) 0x61,(byte) 0x72,(byte) 0x74,(byte) 0x01,(byte) 0x00,(byte) 0x01,(byte) 0x4a,(byte) 0x01,(byte) 0x00,(byte) 0x0d,(byte) 0x43,(byte) 0x6f,(byte) 0x6e,(byte) 0x73,(byte) 0x74,(byte) 0x61,(byte) 0x6e,(byte) 0x74,(byte) 0x56,(byte) 0x61,(byte) 0x6c,(byte) 0x75,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x03,(byte) 0x65,(byte) 0x6e,(byte) 0x64,(byte) 0x01,(byte) 0x00,(byte) 0x05,(byte) 0x6d,(byte) 0x6f,(byte) 0x64,(byte) 0x75,(byte) 0x6c,(byte) 0x01,(byte) 0x00,(byte) 0x09,(byte) 0x70,(byte) 0x75,(byte) 0x62,(byte) 0x6c,(byte) 0x69,(byte) 0x63,(byte) 0x4b,(byte) 0x65,(byte) 0x79,(byte) 0x01,(byte) 0x00,(byte) 0x06,(byte) 0x3c,(byte) 0x69,(byte) 0x6e,(byte) 0x69,(byte) 0x74,(byte) 0x3e,(byte) 0x01,(byte) 0x00,(byte) 0x03,(byte) 0x28,(byte) 0x29,(byte) 0x56,(byte) 0x01,(byte) 0x00,(byte) 0x04,(byte) 0x43,(byte) 0x6f,(byte) 0x64,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x0f,(byte) 0x4c,(byte) 0x69,(byte) 0x6e,(byte) 0x65,(byte) 0x4e,(byte) 0x75,(byte) 0x6d,(byte) 0x62,(byte) 0x65,(byte) 0x72,(byte) 0x54,(byte) 0x61,(byte) 0x62,(byte) 0x6c,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x03,(byte) 0x72,(byte) 0x75,(byte) 0x6e,(byte) 0x01,(byte) 0x00,(byte) 0x0e,(byte) 0x28,(byte) 0x29,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x0d,(byte) 0x53,(byte) 0x74,(byte) 0x61,(byte) 0x63,(byte) 0x6b,(byte) 0x4d,(byte) 0x61,(byte) 0x70,(byte) 0x54,(byte) 0x61,(byte) 0x62,(byte) 0x6c,(byte) 0x65,(byte) 0x07,(byte) 0x00,(byte) 0x36,(byte) 0x01,(byte) 0x00,(byte) 0x0c,(byte) 0x74,(byte) 0x72,(byte) 0x79,(byte) 0x5f,(byte) 0x74,(byte) 0x6f,(byte) 0x5f,(byte) 0x63,(byte) 0x72,(byte) 0x61,(byte) 0x63,(byte) 0x6b,(byte) 0x01,(byte) 0x00,(byte) 0x04,(byte) 0x28,(byte) 0x4a,(byte) 0x29,(byte) 0x5a,(byte) 0x01,(byte) 0x00,(byte) 0x0a,(byte) 0x53,(byte) 0x6f,(byte) 0x75,(byte) 0x72,(byte) 0x63,(byte) 0x65,(byte) 0x46,(byte) 0x69,(byte) 0x6c,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x0f,(byte) 0x43,(byte) 0x72,(byte) 0x61,(byte) 0x63,(byte) 0x6b,(byte) 0x4a,(byte) 0x4f,(byte) 0x42,(byte) 0x49,(byte) 0x44,(byte) 0x2e,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x0c,(byte) 0x00,(byte) 0x25,(byte) 0x00,(byte) 0x26,(byte) 0x0c,(byte) 0x00,(byte) 0x1f,(byte) 0x00,(byte) 0x20,(byte) 0x0c,(byte) 0x00,(byte) 0x22,(byte) 0x00,(byte) 0x20,(byte) 0x0c,(byte) 0x00,(byte) 0x23,(byte) 0x00,(byte) 0x20,(byte) 0x0c,(byte) 0x00,(byte) 0x24,(byte) 0x00,(byte) 0x20,(byte) 0x01,(byte) 0x00,(byte) 0x0a,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x0c,(byte) 0x00,(byte) 0x25,(byte) 0x00,(byte) 0x49,(byte) 0x01,(byte) 0x00,(byte) 0x0a,(byte) 0x43,(byte) 0x72,(byte) 0x61,(byte) 0x63,(byte) 0x6b,(byte) 0x4a,(byte) 0x4f,(byte) 0x42,(byte) 0x49,(byte) 0x44,(byte) 0x0c,(byte) 0x00,(byte) 0x2d,(byte) 0x00,(byte) 0x2e,(byte) 0x01,(byte) 0x00,(byte) 0x18,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x24,(byte) 0x50,(byte) 0x61,(byte) 0x72,(byte) 0x74,(byte) 0x69,(byte) 0x61,(byte) 0x6c,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x01,(byte) 0x00,(byte) 0x0d,(byte) 0x50,(byte) 0x61,(byte) 0x72,(byte) 0x74,(byte) 0x69,(byte) 0x61,(byte) 0x6c,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x01,(byte) 0x00,(byte) 0x0c,(byte) 0x49,(byte) 0x6e,(byte) 0x6e,(byte) 0x65,(byte) 0x72,(byte) 0x43,(byte) 0x6c,(byte) 0x61,(byte) 0x73,(byte) 0x73,(byte) 0x65,(byte) 0x73,(byte) 0x07,(byte) 0x00,(byte) 0x4a,(byte) 0x0c,(byte) 0x00,(byte) 0x4b,(byte) 0x00,(byte) 0x4c,(byte) 0x07,(byte) 0x00,(byte) 0x4d,(byte) 0x0c,(byte) 0x00,(byte) 0x4f,(byte) 0x00,(byte) 0x50,(byte) 0x01,(byte) 0x00,(byte) 0x17,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x42,(byte) 0x75,(byte) 0x69,(byte) 0x6c,(byte) 0x64,(byte) 0x65,(byte) 0x72,(byte) 0x0c,(byte) 0x00,(byte) 0x51,(byte) 0x00,(byte) 0x52,(byte) 0x01,(byte) 0x00,(byte) 0x05,(byte) 0x3a,(byte) 0x74,(byte) 0x72,(byte) 0x75,(byte) 0x65,(byte) 0x0c,(byte) 0x00,(byte) 0x51,(byte) 0x00,(byte) 0x53,(byte) 0x0c,(byte) 0x00,(byte) 0x54,(byte) 0x00,(byte) 0x55,(byte) 0x0c,(byte) 0x00,(byte) 0x25,(byte) 0x00,(byte) 0x56,(byte) 0x0c,(byte) 0x00,(byte) 0x57,(byte) 0x00,(byte) 0x58,(byte) 0x01,(byte) 0x00,(byte) 0x0a,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x73,(byte) 0x72,(byte) 0x63,(byte) 0x01,(byte) 0x00,(byte) 0x04,(byte) 0x28,(byte) 0x49,(byte) 0x29,(byte) 0x56,(byte) 0x01,(byte) 0x00,(byte) 0x10,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x4f,(byte) 0x62,(byte) 0x6a,(byte) 0x65,(byte) 0x63,(byte) 0x74,(byte) 0x01,(byte) 0x00,(byte) 0x08,(byte) 0x67,(byte) 0x65,(byte) 0x74,(byte) 0x43,(byte) 0x6c,(byte) 0x61,(byte) 0x73,(byte) 0x73,(byte) 0x01,(byte) 0x00,(byte) 0x13,(byte) 0x28,(byte) 0x29,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x43,(byte) 0x6c,(byte) 0x61,(byte) 0x73,(byte) 0x73,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x15,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x24,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x54,(byte) 0x79,(byte) 0x70,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x0a,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x54,(byte) 0x79,(byte) 0x70,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x05,(byte) 0x56,(byte) 0x61,(byte) 0x6c,(byte) 0x75,(byte) 0x65,(byte) 0x01,(byte) 0x00,(byte) 0x17,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x24,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x54,(byte) 0x79,(byte) 0x70,(byte) 0x65,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x06,(byte) 0x61,(byte) 0x70,(byte) 0x70,(byte) 0x65,(byte) 0x6e,(byte) 0x64,(byte) 0x01,(byte) 0x00,(byte) 0x1c,(byte) 0x28,(byte) 0x4a,(byte) 0x29,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x42,(byte) 0x75,(byte) 0x69,(byte) 0x6c,(byte) 0x64,(byte) 0x65,(byte) 0x72,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x2d,(byte) 0x28,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x3b,(byte) 0x29,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x42,(byte) 0x75,(byte) 0x69,(byte) 0x6c,(byte) 0x64,(byte) 0x65,(byte) 0x72,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x08,(byte) 0x74,(byte) 0x6f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x01,(byte) 0x00,(byte) 0x14,(byte) 0x28,(byte) 0x29,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x53,(byte) 0x74,(byte) 0x72,(byte) 0x69,(byte) 0x6e,(byte) 0x67,(byte) 0x3b,(byte) 0x01,(byte) 0x00,(byte) 0x38,(byte) 0x28,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x3b,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x24,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x54,(byte) 0x79,(byte) 0x70,(byte) 0x65,(byte) 0x3b,(byte) 0x4c,(byte) 0x6a,(byte) 0x61,(byte) 0x76,(byte) 0x61,(byte) 0x2f,(byte) 0x6c,(byte) 0x61,(byte) 0x6e,(byte) 0x67,(byte) 0x2f,(byte) 0x4f,(byte) 0x62,(byte) 0x6a,(byte) 0x65,(byte) 0x63,(byte) 0x74,(byte) 0x3b,(byte) 0x29,(byte) 0x56,(byte) 0x01,(byte) 0x00,(byte) 0x03,(byte) 0x61,(byte) 0x64,(byte) 0x64,(byte) 0x01,(byte) 0x00,(byte) 0x28,(byte) 0x28,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x24,(byte) 0x50,(byte) 0x61,(byte) 0x72,(byte) 0x74,(byte) 0x69,(byte) 0x61,(byte) 0x6c,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x3b,(byte) 0x29,(byte) 0x4c,(byte) 0x4a,(byte) 0x6f,(byte) 0x62,(byte) 0x2f,(byte) 0x52,(byte) 0x65,(byte) 0x73,(byte) 0x75,(byte) 0x6c,(byte) 0x74,(byte) 0x3b,(byte) 0x00,(byte) 0x21,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x1e,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x04,(byte) 0x00,(byte) 0x12,(byte) 0x00,(byte) 0x1f,(byte) 0x00,(byte) 0x20,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x21,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x12,(byte) 0x00,(byte) 0x22,(byte) 0x00,(byte) 0x20,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x21,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x05,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x23,(byte) 0x00,(byte) 0x20,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x24,(byte) 0x00,(byte) 0x20,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x03,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x25,(byte) 0x00,(byte) 0x26,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x27,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x49,(byte) 0x00,(byte) 0x03,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x21,(byte) 0x2a,(byte) 0xb7,(byte) 0x00,(byte) 0x01,(byte) 0x2a,(byte) 0x14,(byte) 0x00,(byte) 0x02,(byte) 0xb5,(byte) 0x00,(byte) 0x04,(byte) 0x2a,(byte) 0x14,(byte) 0x00,(byte) 0x05,(byte) 0xb5,(byte) 0x00,(byte) 0x07,(byte) 0x2a,(byte) 0x14,(byte) 0x00,(byte) 0x08,(byte) 0xb5,(byte) 0x00,(byte) 0x0a,(byte) 0x2a,(byte) 0x14,(byte) 0x00,(byte) 0x0b,(byte) 0xb5,(byte) 0x00,(byte) 0x0d,(byte) 0xb1,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x28,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x05,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x04,(byte) 0x00,(byte) 0x04,(byte) 0x00,(byte) 0x05,(byte) 0x00,(byte) 0x0b,(byte) 0x00,(byte) 0x06,(byte) 0x00,(byte) 0x12,(byte) 0x00,(byte) 0x07,(byte) 0x00,(byte) 0x19,(byte) 0x00,(byte) 0x08,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x29,(byte) 0x00,(byte) 0x2a,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x27,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x8e,(byte) 0x00,(byte) 0x08,(byte) 0x00,(byte) 0x04,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x4f,(byte) 0xbb,(byte) 0x00,(byte) 0x0e,(byte) 0x59,(byte) 0x12,(byte) 0x0f,(byte) 0xb7,(byte) 0x00,(byte) 0x10,(byte) 0x4c,(byte) 0x14,(byte) 0x00,(byte) 0x02,(byte) 0x41,(byte) 0x20,(byte) 0x14,(byte) 0x00,(byte) 0x05,(byte) 0x94,(byte) 0x9c,(byte) 0x00,(byte) 0x3a,(byte) 0x2a,(byte) 0x20,(byte) 0xb6,(byte) 0x00,(byte) 0x12,(byte) 0x99,(byte) 0x00,(byte) 0x2b,(byte) 0x2b,(byte) 0xbb,(byte) 0x00,(byte) 0x13,(byte) 0x59,(byte) 0x2b,(byte) 0x59,(byte) 0xb6,(byte) 0x00,(byte) 0x14,(byte) 0x57,(byte) 0xb2,(byte) 0x00,(byte) 0x15,(byte) 0xbb,(byte) 0x00,(byte) 0x16,(byte) 0x59,(byte) 0xb7,(byte) 0x00,(byte) 0x17,(byte) 0x20,(byte) 0xb6,(byte) 0x00,(byte) 0x18,(byte) 0x12,(byte) 0x19,(byte) 0xb6,(byte) 0x00,(byte) 0x1a,(byte) 0xb6,(byte) 0x00,(byte) 0x1b,(byte) 0xb7,(byte) 0x00,(byte) 0x1c,(byte) 0xb6,(byte) 0x00,(byte) 0x1d,(byte) 0x57,(byte) 0x20,(byte) 0x0a,(byte) 0x61,(byte) 0x41,(byte) 0xa7,(byte) 0xff,(byte) 0xc4,(byte) 0x2b,(byte) 0xb0,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x28,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x1a,(byte) 0x00,(byte) 0x06,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x0b,(byte) 0x00,(byte) 0x0a,(byte) 0x00,(byte) 0x0c,(byte) 0x00,(byte) 0x16,(byte) 0x00,(byte) 0x0d,(byte) 0x00,(byte) 0x1e,(byte) 0x00,(byte) 0x0e,(byte) 0x00,(byte) 0x46,(byte) 0x00,(byte) 0x0c,(byte) 0x00,(byte) 0x4d,(byte) 0x00,(byte) 0x11,(byte) 0x00,(byte) 0x2b,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x0d,(byte) 0x00,(byte) 0x03,(byte) 0xfd,(byte) 0x00,(byte) 0x0e,(byte) 0x07,(byte) 0x00,(byte) 0x2c,(byte) 0x04,(byte) 0x37,(byte) 0xfa,(byte) 0x00,(byte) 0x06,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x2d,(byte) 0x00,(byte) 0x2e,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x27,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x39,(byte) 0x00,(byte) 0x04,(byte) 0x00,(byte) 0x03,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x16,(byte) 0x2a,(byte) 0xb4,(byte) 0x00,(byte) 0x0d,(byte) 0x1f,(byte) 0x69,(byte) 0x2a,(byte) 0xb4,(byte) 0x00,(byte) 0x0a,(byte) 0x71,(byte) 0x0a,(byte) 0x94,(byte) 0x9a,(byte) 0x00,(byte) 0x07,(byte) 0x04,(byte) 0xa7,(byte) 0x00,(byte) 0x04,(byte) 0x03,(byte) 0xac,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x28,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x06,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x14,(byte) 0x00,(byte) 0x2b,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x05,(byte) 0x00,(byte) 0x02,(byte) 0x14,(byte) 0x40,(byte) 0x01,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x2f,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x30,(byte) 0x00,(byte) 0x3c,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x12,(byte) 0x00,(byte) 0x02,(byte) 0x00,(byte) 0x13,(byte) 0x00,(byte) 0x0e,(byte) 0x00,(byte) 0x3b,(byte) 0x00,(byte) 0x01,(byte) 0x00,(byte) 0x3f,(byte) 0x00,(byte) 0x0e,(byte) 0x00,(byte) 0x4e,(byte) 0x40,(byte) 0x19}; @Override - public void run() { - if(testsperrun >= mod) { - enque(1, mod, jobmanager.jobs_total()+1); + public boolean enquenextJob() { + if(i >= mod) { + System.out.println("encryption done!"); + return false; } - - for(long i = 1; i < mod; i+= testsperrun) { - enque(i, i+testsperrun, jobmanager.jobs_total()+1); - } - } - - private void enque(long from, long to, int jobid) { -// System.out.println("from: " + from + " to: " + to); - String code = "import Job.Jobsrc;\nimport Job.Result;\nimport Job.Result.ResultType;\npublic class Crack" + jobid + " extends Jobsrc {\n private final long start = " + from + "L; private final long end = " + to + "L; private long modul = " + mod + "L; private long publicKey = " + public_key + "L; \n @Override\n public Result run() {\n Result out = new Result(" + jobid + ");\n for(long i = start; i < end; i++) {\n if(try_to_crack(i))\n {out.add(out.new PartialResult(ResultType.Value, i + \":true\"));\n}\n }\n return out;\n }\n public boolean try_to_crack(long i) {\n /*System.out.println(\"Testing\"+i);*/ return (publicKey * i) % modul == 1;\n }\n}"; - jobmanager.enque(new Job(code)); + enque(i, testsperrun >= mod ? mod : i+testsperrun, getJobManager().jobs_total()+1); + i+=testsperrun; + return i < mod; } + private void enque(long from, long to, int jobid) { + // System.out.println("from: " + from + " to: " + to); + +// String code = "import Job.Jobsrc;\nimport Job.Result;\nimport Job.Result.ResultType;\npublic class Crack" + jobid + " extends Jobsrc {\n private final long start = " + from + "L; private final long end = " + to + "L; private long modul = " + mod + "L; private long publicKey = " + public_key + "L; \n @Override\n public Result run() {\n Result out = new Result(" + jobid + ");\n for(long i = start; i < end; i++) {\n if(try_to_crack(i))\n {out.add(out.new PartialResult(ResultType.Value, i + \":true\"));\n}\n }\n return out;\n }\n public boolean try_to_crack(long i) {\n /*System.out.println(\"Testing\"+i);*/ return (publicKey * i) % modul == 1;\n }\n}"; +// getJobManager().enque(new Job(code), false); + //enque with precompiled code! test! + Job newjob = new Job(""); + newjob.classname = "Crack" + String.format("%05d", jobid); + newjob.compiled = true; + + byte[] jobidb = stringtoBytes(String.format("%05d", jobid)); + byte[] bytes = replace(precompiledcode.clone(), 0x143 , jobidb); + bytes = replace(bytes, 0x180 , jobidb); + bytes = replace(bytes, 0x10, longtoBytes(from)); + bytes = replace(bytes, 0x1E, longtoBytes(to)); + bytes = replace(bytes, 0x2C, longtoBytes(mod)); + bytes = replace(bytes, 0x3A, longtoBytes(public_key)); + bytes = replace(bytes, 0x4B, inttoBytes(jobid)); + newjob.classfile = bytes; + getJobManager().enque(newjob, true); + System.out.println("enqued job with classname: " + newjob.classname + " and jobid: " + newjob.getId()); + } + + private byte[] replace(byte[] old, int start, byte[] new_) { + for(int i = start; i - start < new_.length; i++) { + old[i] = new_[i-start]; + } + return old; + } + @Override public void HandlePartialResult(PartialResult pres) { String in = (String) pres.obj; @@ -51,7 +81,7 @@ public class CryptCrack extends Program { } System.out.println("KEY FOUND!\nkey = " + key); - jobmanager.clear();//stop this job + getJobManager().clear();//stop this job } } } \ No newline at end of file diff --git a/BBEncryptionCracker/test/CrackJOBID.class b/BBEncryptionCracker/test/CrackJOBID.class new file mode 100644 index 0000000000000000000000000000000000000000..3b65f925e0fc72442be1db7252e09b149344fbbe GIT binary patch literal 1308 zcmaJ>T~8ZF6g`7&)@;@$F$O}K2B)Qou?sW}`NC=Va7t_Q86Xhn1+DEBTDn;~>)lBF zi9F?{Ro^33eQ2v^OXNu+wEd*{qObMKiuGd_O*<}H9}lvG^7 zjR?p5{nF~g1$^B>f4`ULW(OS~OEldLF0Hs4`+$`6__jbeU#pVeziisZs`spHI9qzzk{KM&7Ko?Emy5OX z)P~XUEH}qOo338@VMVX|H10+~bDe`-x3*hx7-7bAar~)(x>@s_im_~hA|*#lFz+5)NX1FRKn z+i>!h-e?#N1w{=@SXQv2VGZj7!&1$ZrQ3T`o33NpdkdavRSieOBW$pNGp^$q5^QSN z!egmuTf+{Xbc9k!!>Pzk7i2fjchjwv_l*iqC%R|2etCfbHnU6cC)v@#z-HRJ*gB}Q zXKD~cI_EkZIE}F`foXd6dfh+t%j|!k%$aSGH0m5CMWw9(yP3t>0pAh2TEz(_T+GtujLA#T^I>@c_26g^zci_dvuB;oZ*%7 zW4u-LA;x&;Xs;6$d<y?Mvb?S!*rCONss?oL^?{`4lt1`WZ8sR1=9GkSQsp?LZhGe+0k~7%J|QNq0FC%jheLTbM@6vP{OYf4*hysLaqXmemb@>IVV_q W$`5~q`}7Io0oKitI7`1eH}W4p>=#l1 literal 0 HcmV?d00001 diff --git a/Server/BesenBoincServer/src/Comunication/Client.java b/Server/BesenBoincServer/src/Comunication/Client.java index 922b22b..d5ce3f6 100755 --- a/Server/BesenBoincServer/src/Comunication/Client.java +++ b/Server/BesenBoincServer/src/Comunication/Client.java @@ -67,7 +67,7 @@ public class Client implements Runnable{ soc.close(); System.out.println("Disconnected!"); //re-enque all take jobs - Server.getServer().getProgram().jobmanager.reenque(takenjobs); + Server.getServer().getProgram().getJobManager().reenque(takenjobs); takenjobs.clear(); } catch (IOException e) { e.printStackTrace(); @@ -76,13 +76,14 @@ public class Client implements Runnable{ @Override public void run() { - while(!soc.isClosed() & hold_connection) { + while(!soc.isClosed() && hold_connection) { //handle data try { handler.HandleData((Data) in.readObject(), this); // System.out.println("Recived data!"); } catch (Exception e) { - e.printStackTrace(); +// e.printStackTrace(); + System.err.println("Error while reciving! Disconnecting Client: " + soc.getInetAddress() ); disconnect(); } } diff --git a/Server/BesenBoincServer/src/Comunication/Server.java b/Server/BesenBoincServer/src/Comunication/Server.java index 5057eca..cefa1ec 100755 --- a/Server/BesenBoincServer/src/Comunication/Server.java +++ b/Server/BesenBoincServer/src/Comunication/Server.java @@ -46,7 +46,7 @@ public class Server implements PacketHandler { connections.add(c); execution.submit(c); c.send(new Data("welcomme")); - prog.jobmanager.update(); + prog.getJobManager().update(); } catch (IOException e) { e.printStackTrace(); } @@ -60,8 +60,8 @@ public class Server implements PacketHandler { programthread = new Thread(new Runnable() { @Override public void run() { - prog.run(); - System.out.println("Program enqued " + prog.jobmanager.jobs_total() + " Jobs."); + for(int i = 0; i < 15 && prog.enquenextJob(); i++);//enque 15 start jobs + System.out.println("Program enqued " + prog.getJobManager().jobs_total() + " Jobs."); } }, "Programm Thread"); programthread.start(); @@ -114,8 +114,8 @@ public class Server implements PacketHandler { c.send(new Data("pingback")); // System.out.println("Pinged, pining back..."); } else if(info.equalsIgnoreCase("nextplease")) { - if(prog.jobmanager.hasNext()) { - c.send(new Data(prog.jobmanager.next(),ContentType.Job)); + if(prog.getJobManager().hasNext()) { + c.send(new Data(prog.getJobManager().next(),ContentType.Job)); } else { System.out.println("Out of Tasks"); } diff --git a/Server/BesenBoincServer/src/Core/Program.java b/Server/BesenBoincServer/src/Core/Program.java index 98da7db..499352c 100755 --- a/Server/BesenBoincServer/src/Core/Program.java +++ b/Server/BesenBoincServer/src/Core/Program.java @@ -1,12 +1,26 @@ package Core; +import java.nio.ByteBuffer; +import java.util.Arrays; + import Job.JobManager; import Job.Result; import Job.Result.PartialResult; -public abstract class Program implements Runnable { +public abstract class Program{ - public JobManager jobmanager = new JobManager(); + private JobManager jobmanager = new JobManager(this); + + public JobManager getJobManager() { + return jobmanager; + } + + /** + * Called by the JobManager or Server, to get the Program generating the next Job. + * The Program is allowed to sumbit more than one Program to the JobManager. + * returns false, when all jobs are submited + */ + public abstract boolean enquenextJob(); public void HandleResult(Result r) { jobmanager.setdone(r.getJobId()); @@ -20,5 +34,26 @@ public abstract class Program implements Runnable { } } + protected byte[] inttoBytes(int i ) { + return ByteBuffer.allocate(4).putInt(i).array(); + } + + protected byte[] longtoBytes(long i ) { + return ByteBuffer.allocate(8).putLong(i).array(); + } + + /** + * removes the zero terminating byte + * @param s + * @return + */ + protected byte[] stringtoBytes(String s) { + byte[] tmp = s.getBytes(); + if(tmp[tmp.length-1] == 0) { + tmp = Arrays.copyOf(tmp, tmp.length-1); + } + return tmp; + } + public abstract void HandlePartialResult(PartialResult pres); } \ No newline at end of file diff --git a/Server/BesenBoincServer/src/Core/Starter.java b/Server/BesenBoincServer/src/Core/Starter.java index 4e5dcea..8e538a3 100755 --- a/Server/BesenBoincServer/src/Core/Starter.java +++ b/Server/BesenBoincServer/src/Core/Starter.java @@ -53,7 +53,7 @@ public class Starter { Server.getServer().close(); run = false; } else if(in.equalsIgnoreCase("stats")) { - JobManager jm = server.getProgram().jobmanager; + JobManager jm = server.getProgram().getJobManager(); System.out.println("\nStats:\nTasks done : " + jm.jobs_done() + "\nTasks send : " + jm.jobs_send() + "\nTasks compiled: " + jm.jobs_compiled() + "/" + jm.jobs_compiledtarget() + "\nCurrently Compiling: " + jm.isCompiling() + "\nTasks enqued : " + jm.jobs_enqued() + "\n--------------------\ntotal : " + jm.jobs_total()+ "\nConnections: " + server.getConnectionCount()); } else { System.out.println("unknown Command."); diff --git a/Server/BesenBoincServer/src/Job/JobManager.java b/Server/BesenBoincServer/src/Job/JobManager.java index 30e73a5..99e14a9 100755 --- a/Server/BesenBoincServer/src/Job/JobManager.java +++ b/Server/BesenBoincServer/src/Job/JobManager.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Scanner; import Comunication.Server; +import Core.Program; import Utils.StringUtils; public class JobManager implements Iterator{ @@ -19,20 +20,28 @@ public class JobManager implements Iterator{ private List send = new ArrayList();//assigned jobs private List done = new ArrayList();//done jobs + private Program prog; private int jobcount = 0; private boolean isCompiling = false; + public JobManager(Program program) { + prog = program; + } + public void reenque(List jobs) { todo.addAll(0, jobs); send.removeAll(jobs); update(); } - public void enque(Job newjob) { + public void enque(Job newjob, boolean isPreCompiled) { jobcount++; newjob.setId(jobcount); - enqued.add(newjob); + if(isPreCompiled) + todo.add(newjob); + else + enqued.add(newjob); update(); } @@ -45,9 +54,13 @@ public class JobManager implements Iterator{ @Override public void run() { isCompiling = true;//doppelt hält besser -// System.out.println("Compilingque started!"); - while(enqued.size() > 0 & todo.size() < 15 & isCompiling) { + //compile them! + while(enqued.size() > 0 && todo.size() < jobs_compiledtarget() && isCompiling) { Job j = enqued.get(0); + if(j == null) { + System.out.println("enqued.size(): " + enqued.size() + " but job.get(0) is null!"); + break; + } //compile script try { // System.out.println(j.code); @@ -86,20 +99,17 @@ public class JobManager implements Iterator{ enqued.remove(0);//manage ques todo.add(j); - //br.close(); - if(classfile.exists())//delete all files classfile.delete(); if (file.exists()) file.delete(); -// System.out.println("Compile done."); } catch(IOException | InterruptedException e) { e.printStackTrace(); } } isCompiling = false; -// System.out.println("Compiling que Stopped!"); +// System.out.println("Compiler stopped!"); } }, "Compiler"); } @@ -109,20 +119,36 @@ public class JobManager implements Iterator{ */ @Override public boolean hasNext() { - return todo.size() != 0; + if(todo.size() == 0) { + update(); + return false; + } + return true; } @Override public Job next() { + //Warning! not checked if todo.get(0) exists! send.add(todo.get(0)); todo.remove(0); update(); - System.out.println("" + ((int) (((float) done.size()) / ((float)jobs_total()))*100) + "% Done"); + System.out.println(((int) (((float) done.size()) / ((float)jobs_total()))*100) + "% Done"); return send.get(send.size()-1); } - public void update() {//called from Server on new Client Connection - if(enqued.size() > 0 & !isCompiling & todo.size() < jobs_compiledtarget()) {//7 für jede connection vorrätig + /** + * Called, when the job-lists get modified or a new client connects. + * This method simply checks weather the compiler-thread should be started or not. + * If the Thread should be started, this method does it with no further instruction. + */ + public void update() { + boolean hasnext = true;//variable zum testen, ob das Programm weitere Jobs hat + while(enqued.size() + todo.size() < jobs_compiledtarget() && (hasnext = prog.enquenextJob()));//genarte new jobs! + if(!hasnext) { + System.out.println("Program has no new Jobs!"); + //TODO: somehow stop the compile thread after compiling (and disable it from re-opening) and set a flag, that after these jobs are done the server could shutdown. + } + if(enqued.size() > 0 && !isCompiling && todo.size() < jobs_compiledtarget()) {//7 jobs for each connection and at least 10 startCompile(); } } @@ -185,7 +211,7 @@ public class JobManager implements Iterator{ * @param jobId */ public void setdone(int jobId) { - //find yob + //find job Job j = null; int pos = -1; for(int i = 0; i < send.size(); i++) { @@ -199,6 +225,7 @@ public class JobManager implements Iterator{ if(j != null) { send.remove(pos); done.add(j); + //TODO: delete old done jobs, to preverse Memory? } else { System.out.println("Job id " + jobId + " not found"); } diff --git a/test-factorial/BBTestprogram/src/Test.java b/test-factorial/BBTestprogram/src/Test.java index d1adfd7..9cc704b 100755 --- a/test-factorial/BBTestprogram/src/Test.java +++ b/test-factorial/BBTestprogram/src/Test.java @@ -4,12 +4,14 @@ import Job.Result.PartialResult; public class Test extends Program { + private int c = 0; + @Override - public void run() { - for(int c = 5; c < 1000; c++) { - String code = "import Job.Job;\nimport Job.Result;\nimport Job.Result.PartialResult;\nimport Job.Jobsrc;\npublic class A" + c + " extends Jobsrc {\n@Override\npublic Result run() {\ndouble i ="+c+";\nfor(int n = 2; n < " + c + ";n++){\n i *= n;\n}\n Result r = new Result(" + (jobmanager.jobs_total() +1) +");\nr.OutputConsole(\"!"+c+"= \"+i);\n return r;\n }}"; - jobmanager.enque(new Job(code)); - } + public boolean enquenextJob() { + String code = "import Job.Job;\nimport Job.Result;\nimport Job.Result.PartialResult;\nimport Job.Jobsrc;\npublic class A" + c + " extends Jobsrc {\n@Override\npublic Result run() {\ndouble i ="+c+";\nfor(int n = 2; n < " + c + ";n++){\n i *= n;\n}\n Result r = new Result(" + (getJobManager().jobs_total() +1) +");\nr.OutputConsole(\"!"+c+"= \"+i);\n return r;\n }}"; + getJobManager().enque(new Job(code), false); + c++; + return true; } @Override diff --git a/test-primefinder/BBPrimeFinder/src/mrbesen/PrimeFinder.java b/test-primefinder/BBPrimeFinder/src/mrbesen/PrimeFinder.java index d3c688a..27c83a0 100755 --- a/test-primefinder/BBPrimeFinder/src/mrbesen/PrimeFinder.java +++ b/test-primefinder/BBPrimeFinder/src/mrbesen/PrimeFinder.java @@ -15,14 +15,13 @@ import Job.Result.PartialResult; public class PrimeFinder extends Program { List primes = new ArrayList(); - double count = -1; + double count = -1;//current prime File file = new File("primes"); int save_count;//to save every 20 times int save_intervall = 100; - @Override - public void run() { + public PrimeFinder() { //load primes try { if(file.exists()) { @@ -51,7 +50,7 @@ public class PrimeFinder extends Program { count = primes.get(primes.size()-1)+1; String insert = PrimetoString(count); - jobmanager.enque(new Job("import Job.Jobsrc;\nimport Job.Result;\nimport Job.Result.ResultType;\npublic class A" + insert + " extends Jobsrc{\n double num = " + insert + ";\n @Override\n public Result run() {\n Result r = new Result();\n for(double test = num; test < num + 200; test = test +2) {\n for(double i = 2; i * i <= test+2; i++) {\n if(test%i == 0)\n r.add(r.new PartialResult(ResultType.Value, test + \"|\" + false));\n }\n r.add(r.new PartialResult(ResultType.Value, test + \"|\" + true));\n }\n return r;\n }\n}") ); + getJobManager().enque(new Job("import Job.Jobsrc;\nimport Job.Result;\nimport Job.Result.ResultType;\npublic class A" + insert + " extends Jobsrc{\n double num = " + insert + ";\n @Override\n public Result run() {\n Result r = new Result();\n for(double test = num; test < num + 200; test = test +2) {\n for(double i = 2; i * i <= test+2; i++) {\n if(test%i == 0)\n r.add(r.new PartialResult(ResultType.Value, test + \"|\" + false));\n }\n r.add(r.new PartialResult(ResultType.Value, test + \"|\" + true));\n }\n return r;\n }\n}"), false); count+= 200; } @@ -67,11 +66,9 @@ public class PrimeFinder extends Program { fw.close(); System.out.println("Primes saved"); } - + private String PrimetoString(double prime) { - String out = prime + ""; - out = out.substring(0,out.length()-2); - return out; + return ((int) prime) / 100 + ""; } @Override @@ -87,7 +84,7 @@ public class PrimeFinder extends Program { primes.add(Double.parseDouble(split[0])); } } - + save_count++; if(save_count >=save_intervall) try { @@ -96,4 +93,11 @@ public class PrimeFinder extends Program { e.printStackTrace(); } } + + + @Override + public boolean enquenextJob() { + checkforprime(); + return true; + } } \ No newline at end of file