コード例 #1
0
 private void constrain() {
   BigInteger offset = new BigInteger(Integer.toString(addressSize * (numUsableRows)));
   BigInteger endVal = startVal.add(offset);
   if (endVal.compareTo(scrollBar.getMaximumHP()) > 0) {
     startVal = scrollBar.getMaximumHP().subtract(offset);
     endVal = scrollBar.getMaximumHP();
     scrollBar.setValueHP(startVal);
     model.fireTableDataChanged();
   }
 }
コード例 #2
0
 private void updateFromScrollBar() {
   beginUpdate();
   BigInteger oldStartVal = startVal;
   startVal = scrollBar.getValueHP();
   constrain();
   model.fireTableDataChanged();
   if (oldStartVal != null) {
     modifySelection(oldStartVal.subtract(startVal).intValue() / addressSize);
   }
   endUpdate();
 }
コード例 #3
0
ファイル: CipherChatClient.java プロジェクト: oghenez/mycila
 private void exchangeKeys() {
   try {
     output.write(modulus.toByteArray());
     byte[] buffer = new byte[ciphertextBlockSize];
     input.read(buffer);
     recipModulus = new BigInteger(1, buffer);
   } catch (IOException ioe) {
     System.err.println("Error establishing keys");
   }
 }
コード例 #4
0
 private String bigIntToHexString(BigInteger bi) {
   StringBuffer buf = new StringBuffer();
   buf.append("0x");
   String val = bi.toString(16);
   for (int i = 0; i < ((2 * addressSize) - val.length()); i++) {
     buf.append('0');
   }
   buf.append(val);
   return buf.toString();
 }
コード例 #5
0
ファイル: CipherChatClient.java プロジェクト: oghenez/mycila
 private void makeKeys() {
   PrimeGenerator pg = new PrimeGenerator(513, 10, sr);
   do {
     p = pg.getStrongPrime();
   } while (p.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals(BigIntegerMath.ZERO));
   do {
     q = pg.getStrongPrime();
   } while (q.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals(BigIntegerMath.ZERO));
   modulus = p.multiply(q);
   // Use 3 as enciphering exponent - OK since we are using salt
   decipherExp =
       BigIntegerMath.THREE.modInverse(
           p.subtract(BigIntegerMath.ONE).multiply(q.subtract(BigIntegerMath.ONE)));
   ciphertextBlockSize = (modulus.bitLength() - 1) / 8 + 1;
   // Maximum size of plaintext is 6 bytes less than ciphertext
   // 1 to get under modulus
   // 4 for the salt
   // 1 for a pad byte
   plaintextBlockSize = ciphertextBlockSize - 6;
 }