473,800 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replicating Perl's unpack functionality in C#

1 New Member
Hi,

I am trying to recreate a perl script in C# but have a problem creating a checksum value that a target system needs.

In Perl this checksum is calculated using the unpack function:
Expand|Select|Wrap|Line Numbers
  1. while () {
  2. $checksum += unpack("%32C*", $_);
  3. }
  4. $checksum %= 32767;
  5. close(PACKAGE);
  6. }
where PACKAGE is the .tar file input stream

I need to replicate this in C# but can't find a means of replicating that unpack function.

All help appreciated!

(I know there are much better checksum calculations available but can't change target system so can't change calculation)
Oct 8 '08 #1
1 2477
Plater
7,872 Recognized Expert Expert
My perl is a bit rusty, but it looks like unpack just pulls out a list of variables from a binary string.
%32C says to produce a 32bit checksum of the object instead of the object itself (Presumably the C just tells it to produce a "hex"-string by using unsigned characters?)

I guess you would have to find out what the checksum method they use is and implement that.
Oct 9 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

42
4118
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time. I'm not interested on which language is better in *general*, just for my purpose. My area of research is in CAD algorithms, and I'm sensing the need to resort to something more expedient than C++, bash scripting, or sed scripting.
5
5458
by: grant | last post by:
Hi All, I am pretty new to python and am having a problem intepreting binary data using struct.unpack. I am reading a file containing binary packed data using open with "rb". All the values are coming through fine when using (integer1,) = struct.unpack('l', line) except when line contains "carriage-return" "linefeed" which are valid binary packed values. Error = unpack string size dows not match format. It seems that
4
15610
by: Stacy Mader | last post by:
Greetings all, I have a VMS binary file with weather data. The record on each line is 1xint(8) 12xint(2) Using the perl unpack function, I can decode the binary file like this: <snip>
6
11010
by: WipeOut | last post by:
I am having a problem in a perl script that I can't seem to find an answer for.. The $cost and $retail vars come from another part of the script and would be something like 000134.345 and 000220.202 respectively.. I an then trying to use these values in a calculation like this.. $profit = ($retail - $cost) / $retail * 100;
3
3845
by: Andrew Robert | last post by:
Hey everyone, Maybe you can see something I don't. I need to convert a working piece of perl code to python. The perl code is: sub ParseTrig {
9
5283
by: débutante | last post by:
bonjour tout le monde je veux installer perl soous cygwin. pour y procéder voici nles étapes ke g fait: 1) g téléchargé activeperl et je l'ai installé => résultat: c/perl le perl toune correctement 2) g installé le cygwin 3) g essayé la comande suivante $ brw_tools unpack bash: ./brw_tools: /usr/local/bin/perl: bad interpreter: No such file or directo ry
7
55149
numberwhun
by: numberwhun | last post by:
**NOTE: This article is written using the 5.8.8 Alpha2 release of Strawberry Perl. I am writing this article with much joy and glee. This is due to the fact that Active State no longer has a monopoly on the issue of Perl on the Windows platform As anyone who code's Perl on the Windows platform knows, the choice that you have (had) for Perl on Windows was Active State. It worked great for your scripting but when it came to installing...
9
4980
by: aliusman | last post by:
Hi Every one, I have a perl script which uses the following code to decode the username saved in a cookie. I want to parse that cookie in php for adding some more features in the application. The source application in perl but I don't know any thing about perl. Here is the code ... @table = (('A' .. 'Z'), ('a' .. 'z'), ('0' .. '9'), '+', '/', '|'); for ($_ = 0; $_ <= $#table; $_++) { $decode_table)] = $_; } local $_ = $_;
2
2138
by: miztaken | last post by:
Hi there, can somebody convert the following perl code to C++ sub OleUnpackPackages { my($this, $explodeinto, $parentname, @NativeFilenames) = @_; my($infh, $byte, $number, $buffer, $outname); my($finished); OLEFILE: foreach my $inname (@NativeFilenames) {
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.