ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Well For one I need to know how to open the video file as a hex string in python. I tried the
but the idle went being busy and it still is at the moment of this typing. second how do I proceed to make a program that calculates the hash as described below
Suppose a web site hosts large video file F that anyone can download. Browsers who download the file need to make sure the file is authentic before displaying the content to the user, So Instead of computing a hash of the entire file, the web site breaks the file into 1KB blocks (1024 bytes). It computes the hash of the last block and appends the value to the second to last block. It then computes the hash of this augmented second to last block and appends the resulting hash to the third block from the end. This process continues from the last block to the first as in the following diagram
When appending the hash value to each block, please append it as binary data, that is, as 32 unencoded bytes (which is 256 bits). If the file size is not a multiple of 1KB then the very last block will be shorter than 1KB, but all other blocks will be exactly 1KB.
You normally wouldn't slurp in a large video file in a single read. One reason is that it may be bigger than your available memory, which will slow things down a lot.
The question talks about processing the file in 1024 byte blocks. The read command can take a parameter which is the number of bytes, so it would make sense to only read in 1024 bytes at a time.
Another hint is that it would be wise to open the file in binary mode ("rb" instead of "r"), so that no changes are made to any characters.
Don't think of reading it as a 'hex string'; hexadecimal is just a human representation of the data. Unless a question explicitly talks about converting to hex (which it doesn't), the data is just a string of bytes - it doesn't matter if the bytes represent characters or numbers or video or whatever.