Cipher text:
5effffffc15fffffffc46b26ffffffcd56ffffffdfffffffd0113556ffffffcd2ffffff9bffffffd1ffffffa4670fffffff1fffffff640ffffffc7761ffffffb5ffffffb2ffffffb36ffffffcb

Encrypted text:
5effffffffffffffffffffffffffffffc15fffffffffffffffffffffffffffffffc46b26ffffffffffffffffffffffffffffffcd56ffffffffffffffffffffffffffffffdfffffffffffffffffffffffffffffffd0113556ffffffffffffffffffffffffffffffcd2ffffffffffffffffffffffff9ffffffbffffffffffffffffffffffffd1ffffffffffffffffffffffffa4670fffffffffffffffffffffffffffffff1fffffffffffffffffffffffffffffff640ffffffffffffffffffffffffffffffc7761ffffffffffffffffffffffffb5ffffffffffffffffffffffffb2ffffffffffffffffffffffffb36ffffffffffffffffffffffffffffffcb

Main Codes:
            byte[] encryptedBytes = <some bytes of your choice>;
            String encryptedHex = ByteToHex(encryptedBytes);
            System.out.println("Cipher text: " + encryptedHex);
            byte[] encryptedBytes2 = HexToByte(encryptedHex);
            System.out.println("Encrypted text: "+ByteToHex
(encryptedBytes2));

I tried to convert some bytes to hex then reconvert the hex back to
bytes. Somehow as you noticed from the results that both text's
patterns are the same except that the encrypted text is far more
'bloated' than the cipher text. It has lots more 'ffffffff' in it.

Below is the HexToByte and ByteToHex codes:

    public String ByteToHex(byte[] byteArray) {
        StringBuffer hexstr = new StringBuffer();
        for (int i = 0; i < byteArray.length; i++) {
            String hexcode = Integer.toHexString(byteArray[i]);
            hexstr.append(hexcode);
        }
        return hexstr.toString();
    }

    public byte[] HexToByte(String hexcode) {
        byte[] bytes = new BigInteger(hexcode.toString(),
16).toByteArray();
        return bytes;
    }

May i know if there's anything wrong with my HexToByte and ByteToHex
codes ?

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to h2-datab...@googlegroups.com.
To unsubscribe from this group, send email to 
h2-database+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to