Cryptography Reference
In-Depth Information
//Method to rectify the extra bit problem of the toByteArray() method
private static byte[] getBytes(BigInteger big) {
byte[] bigBytes=big.toByteArray();
if (big.bitLength()%8!=0) return bigBytes;
else {
byte[] smallerBytes=new byte[big.bitLength()/8];
System.arraycopy(bigBytes,1,smallerBytes,0,smallerBytes.length);
return smallerBytes;
}
}
This is the end of the Ciphers class. More methods will be added later, as we develop more
cryptosystems.
}
I have written an applet called TestBlockAffineCipherApplet to test this cipher. The
applet can be viewed online at the topic's website. Two screen shots are shown in Figures
5.5 and 5.6.
FIGURE 5.5
Search WWH ::




Custom Search