Exemplo n.º 1
0
        /**
         * Creates a new Content object given be the raw byte data
         *
         * @param input
         *            0x30 byte of data from the TMD (starting at 0xB04)
         * @return content object
         */
        public static Content parseContent(byte[] input)
        {
            if (input == null || input.Length != CONTENT_SIZE)
            {
                //MessageBox.Show("Error: invalid Content byte[] input");
                return(null);
            }
            ByteBuffer buffer = ByteBuffer.allocate(input.Length);

            buffer.put(input);
            buffer.position(0);

            int   ID                = buffer.getInt(0x00);
            short index             = buffer.getShort(0x04);
            short type              = buffer.getShort(0x06);
            long  encryptedFileSize = buffer.getLong(0x08);

            buffer.position(0x10);
            byte[] hash = new byte[0x14];
            buffer.get(hash, 0x00, 0x14);
            byte[] hash2 = new byte[0x06];
            buffer.get(hash2, 0x00, 0x06);


            ContentParam param = new ContentParam();

            param.ID                = (ID);
            param.Index             = (index);
            param.Type              = (type);
            param.EncryptedFileSize = (encryptedFileSize);
            param.SHA2Hash          = (hash);

            return(new Content(param));
        }
Exemplo n.º 2
0
 public Content(ContentParam param)
 {
     this.ID                = param.ID;
     this.index             = param.Index;
     this.type              = param.Type;
     this.encryptedFileSize = param.EncryptedFileSize;
     this.SHA2Hash          = param.SHA2Hash;
 }