0

I must get the output of 56 bytes of raw binary in hexadecimal format. The below coding is what I have tried, but I am getting wrong output.

This is the output I am expecting:

0xd19f261efa71440103519930f483de39c4deffb333c35b89c88d505ad4203e98b0d1f34233dad8‌​2a4b9ba0a3531ede93203691a2b96fb45a

But I am getting different output:

87168739A1D8972742F476D48F139348B06EDF38545BC3C00434DD5C464B2FDF8512EF75D05D897E‌​A5523F8C1589AB5106A5CC986C859CBB

     private byte[] encryptByTea(String info){

     byte[] temp = info.getBytes();
     int n = 8 - temp.length % 8;//Multiple if temp number less than 8, need to fill     in the numbers
     byte[] encryptStr = new byte[temp.length + n];
     encryptStr[0] = (byte)n;
     System.arraycopy(temp, 0, encryptStr, n, temp.length);
     byte[] result = new byte[encryptStr.length];
     for(int offset = 0; offset <result.length; offset += 8){
     byte[] tempEncrpt = tea.encrypt(encryptStr, offset, KEY, 32);
     System.arraycopy(tempEncrpt, 0, result, offset, 8);
     }
     return result;
     }

     //Through the TEA algorithm decryption information
     private String decryptByTea(byte[] secretInfo){
     byte[] decryptStr = null;
     byte[] tempDecrypt = new byte[secretInfo.length];
     for(int offset = 0; offset <secretInfo.length; offset += 8){
     decryptStr = tea.decrypt(secretInfo, offset, KEY, 32);
     System.arraycopy(decryptStr, 0, tempDecrypt, offset, 8);
     }

     int n = tempDecrypt[0];
     return new String(tempDecrypt, n, decryptStr.length - n);
     }
Justin
  • 1,972
  • 13
  • 28
  • What output are you getting? – Justin Oct 17 '14 at 04:35
  • This is the output i am expecting 0xd19f261efa71440103519930f483de39c4deffb333c35b89c88d505ad4203e98b0d1f34233dad82a4b9ba0a3531ede93203691a2b96fb45a But i am getting different output 87168739A1D8972742F476D48F139348B06EDF38545BC3C00434DD5C464B2FDF8512EF75D05D897EA5523F8C1589AB5106A5CC986C859CBB – SridharCorby Oct 17 '14 at 05:02
  • You should consider editing the question and adding that information. – Justin Oct 17 '14 at 05:22

0 Answers0