Click here to Skip to main content
15,890,557 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Make window application secure Pin
NarendraSinghJTV26-Jan-10 18:03
NarendraSinghJTV26-Jan-10 18:03 
QuestionRead DXF File Pin
hellogany21-Jan-10 22:44
hellogany21-Jan-10 22:44 
AnswerRe: Read DXF File Pin
DaveAuld21-Jan-10 23:25
professionalDaveAuld21-Jan-10 23:25 
QuestionCRC32 computation and error detection Pin
Gagan.2021-Jan-10 22:26
Gagan.2021-Jan-10 22:26 
AnswerRe: CRC32 computation and error detection Pin
DaveAuld21-Jan-10 23:23
professionalDaveAuld21-Jan-10 23:23 
AnswerRe: CRC32 computation and error detection Pin
Luc Pattyn22-Jan-10 1:40
sitebuilderLuc Pattyn22-Jan-10 1:40 
GeneralRe: CRC32 computation and error detection Pin
Gagan.2022-Jan-10 1:44
Gagan.2022-Jan-10 1:44 
GeneralRe: CRC32 computation and error detection Pin
Luc Pattyn22-Jan-10 2:09
sitebuilderLuc Pattyn22-Jan-10 2:09 
to check for "damage" you need to:
1. have a file
2. calculate some kind of checksum
3. wait
4. calculate the checksum again in an identical way
5. if the results of (2) and (4) don't match, you can be sure the file was modified during (3); if they match, that most likely means the file was not modified.

FWIW: If, between (2) and (4) the file gets transfered to another machine, so (4) is not running where (2) was running, then you also need to transfer the checksum somehow; someone intending to fiddle with your file could also do so to whatever you choose for transferring the checksum

The code I have only calculates the checksum, it does not check anything, nor does it have a GUI.
It has two methods, the first is simply reading all the data reusing the same buffer over and over
(pseudocode shown), the second is "adding" the data to the ongoing CRC.


private static uint[] CRCtable={
				   0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
				   0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
				   0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
				   0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c};

                // this method is pseudo-code only!
		public static uint CalcCRC(string fileName) {
			uint CRC=0;
                        open the file
			byte[] buf=new byte[0x10000];
			for(;;) {
				int count=readBinaryDataFromFileReturningCount(file, buf);
				if (count<=0) break;
				CRC=updateCRC(CRC,buf,count);
			}
			close the file
			return CRC;
		}

                // this is the tricky part:
		private static uint updateCRC(uint CRC, byte[] buf, int count) {
			CRC=~CRC;
			for (int i=0; i< count; i++) {
				byte chr=buf[i];
				uint index=(CRC^chr)&0x0F;
				CRC=(CRC>>4)^CRCtable[index];
				chr>>=4;
				index=(CRC^chr)&0x0F;
				CRC=(CRC>>4)^CRCtable[index];
			}
			return ~CRC;
		}


Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]


modified on Friday, January 22, 2010 12:44 PM

GeneralRe: CRC32 computation and error detection Pin
Gagan.2022-Jan-10 2:17
Gagan.2022-Jan-10 2:17 
GeneralRe: CRC32 computation and error detection [modified] Pin
Luc Pattyn22-Jan-10 3:09
sitebuilderLuc Pattyn22-Jan-10 3:09 
Questionhow to lock keyboard and mouse by vb6 code Pin
zhiyuan1621-Jan-10 22:08
zhiyuan1621-Jan-10 22:08 
QuestionRe: how to lock keyboard and mouse by vb6 code Pin
Eddy Vluggen22-Jan-10 0:22
professionalEddy Vluggen22-Jan-10 0:22 
QuestionHelp, Pretty Please Exporting to Excel Pin
technette21-Jan-10 11:11
technette21-Jan-10 11:11 
AnswerRe: Help, Pretty Please Exporting to Excel Pin
DaveAuld21-Jan-10 12:11
professionalDaveAuld21-Jan-10 12:11 
AnswerRe: Help, Pretty Please Exporting to Excel Pin
Dave Kreskowiak21-Jan-10 12:56
mveDave Kreskowiak21-Jan-10 12:56 
AnswerRe: Help, Pretty Please Exporting to Excel Pin
Rick Shaub22-Jan-10 8:01
Rick Shaub22-Jan-10 8:01 
AnswerRe: Help, Pretty Please Exporting to Excel Pin
technette22-Jan-10 13:46
technette22-Jan-10 13:46 
QuestionWHERE WILL I GET VB.NET PROJECT Pin
rahuldsac21-Jan-10 6:04
rahuldsac21-Jan-10 6:04 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
Dave Kreskowiak21-Jan-10 6:43
mveDave Kreskowiak21-Jan-10 6:43 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
Steven J Jowett21-Jan-10 7:00
Steven J Jowett21-Jan-10 7:00 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
JHizzle21-Jan-10 7:57
JHizzle21-Jan-10 7:57 
JokeRe: WHERE WILL I GET VB.NET PROJECT Pin
Gagan.2022-Jan-10 1:54
Gagan.2022-Jan-10 1:54 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
darkelv22-Jan-10 2:10
darkelv22-Jan-10 2:10 
GeneralRe: WHERE WILL I GET VB.NET PROJECT Pin
Smithers-Jones22-Jan-10 3:51
Smithers-Jones22-Jan-10 3:51 
Questiondatareader error how to solve Pin
Patrício dos Santos21-Jan-10 5:07
Patrício dos Santos21-Jan-10 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.