sub calculate_tcp_checksum($)
{
my ($block) = @_;
my $val = 0;
my @words = unpack "S*", $block;
foreach (@words)
{
$val += $_;
}
while ($val >> 16)
{
$val = ($val >> 16) + ($val & 0xFFFF);
}
$val = ~$val;
return $val & 0xFFFF;
}
cdavies wrote:for every 512 byte block of the tar file, calculate the TCP checksum of that block and concatenate the results, to that append the upload key and calculate the MD5 sum of the whole thing.
sub calculate_tcp_checksum($)
{
my ($block) = @_;
my $val = 0;
my @words = unpack "S*", $block;
foreach (@words)
{
$val += $_;
}
while ($val >> 16)
{
$val = ($val >> 16) + ($val & 0xFFFF);
}
$val = ~$val;
return $val & 0xFFFF;
}
sub checksum_data_by_block($)
{
my ($data) = @_;
my @ret = ();
my $block_size = 512;
my $len = length $data;
my $offset = 0;
while ($offset < $len)
{
my $block = substr $data, $offset, $block_size;
push @ret, calculate_tcp_checksum($block);
$offset += $block_size;
}
return @ret;
}
sub calculate_integrity_digest($)
{
my ($data) = @_;
my @checksums = checksum_data_by_block($data);
my $sumblock = pack "S*", @checksums;
my @bytearray = ();
append_hex_string_to_byte_array($upload_key, \@bytearray);
my $key = pack "C*", @bytearray;
return md5_hex($sumblock . $key);
}
cdavies wrote:Oh, and I wouldn't worry terribly much about crediting me with anything. If you really feel strongly about it, the best thing you can do is link back to this thread so other people know where to get the information from.
alexeena wrote:How do you install ubuntu linux on your PC WITHOUT gettig rid of Windows Vista or XP? Okay, I would like to have linux and Windows Vista both running on one machine. I DON'T want to get rid of Windows Vista, so what do I do after I download linux. I would also like to do the same with XP too. And please NO bad mouthing about windows or windows vista. I happen to like Microsoft and Windows Vista and I DON'T want to get rid of it.
stasiana2 wrote:Hi folks -- I've been reading on the source code. One item of interested me -- upsync. What is this and why do the Python and C++ servers hardcode this to "false" on the StartSession request?
berend wrote:If you run an open-source Gallery 2 (or compatible) server on your home computer, you can configure it as your online destination and Eye-Fi's servers will happily forward your photos to it even while you're away from home. Alternatively, if your computer is always on and is running the Eye-Fi Manager software, you can enable "relayed uploads" and if you're away from home, your photos can be routed through Eye-Fi's servers, allowing your home computer to download them.
Berend
Users browsing this forum: No registered users and 4 guests