I am using a sample code from a git repository to understand twofish algorithm, The code below works very fine the results are also correct checked from an online tool ref http://twofish.online-domain-tools.com/
the problem is as below :-
int[] plainText = new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F };
int[] p = new int[4];
for (int i = 0; i < 4; i++) {
p[i] = plainText[4 * i] + 256 * plainText[4 * i + 1] + (plainText[4 * i + 2] << 16)
+ (plainText[4 * i + 3] << 24);
}
System.out.println("Input:");
Utils.printInput(p);
int[] key = p; //
System.out.println("Key:");
Utils.printInput(key);
//
int[] encrypted = TwoFish.encrypt(p, key);
//
System.out.println("Encrypted:");
Utils.printInput(encrypted);
System.out.println();
int[] decrypted = TwoFish.decrypt(encrypted, key);
System.out.println("Decrypted:");
Utils.printInput(decrypted);
In the code above same key is used as plainText and Key, While there is a requirement of passing plain text and key
int[] encrypted = TwoFish.encrypt(p, key);
above code needs to take input from
int[] encrypted = TwoFish.encrypt("The plain text information", "000102030405060708090A0B0C0D0E0F");