Functionality: CRC32 File Checksum
Clone type: Type-3 (WT3/4)
Is clone: FALSE

Function 1:
public byte [] buildPacket (int padding, SecureRandom random) {
    byte [] packet = new byte [PACKET_SIZE + padding];
    byte [] buffer = m_buffer.getBytes ();
    if (random != null) {
        random.nextBytes (packet);
    } else {
        for (int i = 10 + buffer.length;
        i < packet.length; i ++) {
            packet [i] = 0;
        }
    }
    packet [0] = (byte) ((m_version>> 8) & 0xff);
    packet [1] = (byte) (m_version & 0xff);
    packet [2] = (byte) ((m_type>> 8) & 0xff);
    packet [3] = (byte) (m_type & 0xff);
    packet [4] = 0;
    packet [5] = 0;
    packet [6] = 0;
    packet [7] = 0;
    packet [8] = (byte) ((m_resultCode>> 8) & 0xff);
    packet [9] = (byte) (m_resultCode & 0xff);
    System.arraycopy (buffer, 0, packet, 10, buffer.length);
    if ((10 + buffer.length) < PACKET_SIZE - 1) {
        packet [10 + buffer.length] = 0;
    }
    packet [PACKET_SIZE - 1] = 0;
    CRC32 crc = new CRC32 ();
    crc.update (packet);
    long crc_l = crc.getValue ();
    packet [4] = (byte) ((crc_l>> 24) & 0xff);
    packet [5] = (byte) ((crc_l>> 16) & 0xff);
    packet [6] = (byte) ((crc_l>> 8) & 0xff);
    packet [7] = (byte) (crc_l & 0xff);
    return packet;
}

Function 2:
public static boolean decode (String fileName, ByteArrayOutputStream bos) throws IOException {
    byte [] buffer = new byte [BUFFERSIZE];
    int bufferLength = 0;
    BufferedReader file = new BufferedReader (new InputStreamReader (new FileInputStream (fileName)));
    String line = file.readLine ();
    while (line != null && ! line.startsWith ("=ybegin")) {
        line = file.readLine ();
    }
    if (line == null) throw new IOException ("Error while looking for start of a file.  Could not locate line starting with \"=ybegin\".");

    fileName = parseForName (line);
    if (fileName == null) fileName = "Unknown.blob";

    String partNo = parseForString (line, "part");
    if (partNo != null) {
        while (line != null && ! line.startsWith ("=ypart")) {
            line = file.readLine ();
        }
        if (line == null) throw new IOException ("Error while handling a multipart file.  Could not locate line starting with \"=ypart\".");

    }
    int character;
    boolean special = false;
    line = file.readLine ();
    CRC32 crc = new CRC32 ();
    while (line != null && ! line.startsWith ("=yend")) {
        for (int lcv = 0;
        lcv < line.length (); lcv ++) {
            character = (int) line.charAt (lcv);
            if (character != 61) {
                buffer [bufferLength] = (byte) (special ? character - 106 : character - 42);
                bufferLength ++;
                if (bufferLength == BUFFERSIZE) {
                    bos.write (buffer);
                    crc.update (buffer);
                    bufferLength = 0;
                }
                special = false;
            } else special = true;

        }
        line = file.readLine ();
    }
    if (bufferLength > 0) {
        bos.write (buffer, 0, bufferLength);
        crc.update (buffer, 0, bufferLength);
    }
    file.close ();
    Debug.debug ("Size of output file = " + bos.size ());
    if (line != null && line.startsWith ("=yend")) {
        long fileCRC = - 1;
        String crcVal = parseForString (line, "pcrc32");
        if (crcVal == null) {
            crcVal = parseForCRC (line);
        }
        if (crcVal != null) fileCRC = Long.parseLong (crcVal, 16);

        return fileCRC == crc.getValue ();
    } else return false;

}