RE: Checksums and best way to get'em
RE: Checksums and best way to get'em
- Subject: RE: Checksums and best way to get'em
- From: "Ramakrishna Kondapalli" <email@hidden>
- Date: Tue, 8 Jun 2004 11:54:17 +0530
- Thread-topic: Checksums and best way to get'em
You cal use OS command cksum on the selected file. In cocoa you can call
this through NSTask.
You can also write your own method for example. Make an NSString with
the file content and then call the checksum on NSString
/* Return a checksum of the string, calculated by adding the Unicode
value of each character in the string into an integer total,
ignoring overflow.
*/
-(int) checksum
{
int len = [self length];
int I, total = 0;
for ( i = 0 ; i < len ; i++ )
{
unichar theChar = [self characterAtIndex:i];
total += theChar;
}
return total;
}
If the total value for the file is same (always) => file is not changed
-----Original Message-----
From: April Gendill [
mailto:email@hidden]
Sent: Tuesday, June 08, 2004 11:04 AM
To: email@hidden
Subject: Checksums and best way to get'em
Because I've seen the term applied to so many things I'm not sure
exactly how to ask this question.
But i'll try. How would one generate a checksum of a file and then
using that check sum verify whether or not changes have been made to
the file?
April.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.