|
hey gagan
i have cleared my first problem with the help of registry , but can u please tell me how to work with secure files in c#. i dont know about secure files. it will be very helpful for me
thanks for replay
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
A secret file is nothing but an ordinary file in encrypted format. Use any encryption-decryption algorithm to make a file secure. The same algorithm can be used to store and retieve values in registry so that it can't be read or modified by the user.
|
|
|
|
|
Registry and/or secret file as pointed out by the previous post are good enough for normal use. People can always find the registry key or the secret file and modify it. They can also turn back time briefly to run a trial version of the program if it is setup that way.
To be more secure, you need to gather information about the machine that the setup program had run on, and encrypt it, then save it to the registry. Each time the program is run, it gathers the same information, encrypt it using the same algorithm, and compare the result in the registry. One of these things will happen:
1. The information in the registry is the same as the newly encrypted information. The program can preceed.
2. The information in the registry is different as the newly encrypted information, indicating that the registry was messed with by somebody, or it's a different machine. The program will terminate.
3. The information in the registry is not found. The program will terminate.
The information collected can include things like the MAC address of the NIC, as well as other ID's that are different from machine to machine.
There is a risk that people can install your program on multiple machines, and read the registry to find out what algorighm you used to encrypt the information. They have also to try to find out what information is collected. That take a good effort. Hopefully that will intimidate them off.
For the implementation of a trial version of your program you need to implement similar algorithms but rely on other resources for time, such as that from the Internet. You can also put checks on time consistancy so if you find that the time is messed with, the program simply terminates.
Once any of the above checks fails, the program should put a mark down (also encrypted) so later runs of the program, even though it may pass the checks, will not authorize a "go". The program will be dead.
|
|
|
|
|
hey
thanks for great reply
can u please point out some example to make me easy to work with those conditions, it will be very helpful for me
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi All
Can anyone suggest me an idea for reading .dxf file
Regards
Gany
|
|
|
|
|
DXF file is as per the following http://en.wikipedia.org/wiki/AutoCAD_DXF[^]
You will either need to find a free viewer or library to use these files...or if you have a lot of time to spare, write your own.
|
|
|
|
|
Hi all...
I want to create a simple program which takes a file and compute its hash value, also it will check whether the file is corrupt or damaged or not.
I googled a lot but I did not get any code for that error detection.
If you have any piece of code then suggest me..
Thanks.
Gagan
|
|
|
|
|
If you generate a hash value when the file is generated. and then re-check the hash at a later date, you will know that the file is still the same and not-corrupted if the hash value doesn't change.
Do a search for MD5, SHA1, SHA256 etc.
|
|
|
|
|
Hi,
I have some high-performance C# code that reads any file and calculates a CRC32 for it; it is table-driven to get maximum speed. There is an infinite number of definitions for checksums, hashes and the like, however my code returns the same value that is reported by ZIP utilities such as WinZip.
If you're inexperienced in bit fiddling, you may have some trouble in translating it to another language, especially VB/VB.NET; not sure the automatic translators such as this one[^] would do a good job here.
Interested?
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]
|
|
|
|
|
Thanks for your reply,,,
Could you gimmie some piece of code in C#. Is it possible to judge whether the file is damaged or not by computed hash value??
Thanks.
Gagan
|
|
|
|
|
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};
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;
}
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
|
|
|
|
|
Are you sure a file will have two different hash values after sometime if it is damaged or corrupted??
|
|
|
|
|
No.
I said "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." and nothing else.
There isn't a checksum, hash or anything in the world that will assure this.
The larger the checksum range (i.e. the more bits it uses), the lower the probability of a false match.
If you need to be absolutely sure, you need a check that has at least the same number of bits as the [ADDED] optimal loss-less compressed version of [/ADDED] the actual file itself.
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:56 PM
|
|
|
|
|
dear all
i would like to lock keyboard and mouse when my system is running by vb6, however i got some code here, but when i run, some error is there, any one can help me, urgent, thanks.
Option Explicit
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public hnexthookproc As Long
'Public Const HC_ACTION = 0
'Public Const WH_KEYBOARD = 2
Public Sub UnHookKBD()
If hnexthookproc <> 0 Then
UnhookWindowsHookEx hnexthookpro
hnexthookproc = 0
End If
End Sub
Public Function EnableKBDHook()
If hnexthookproc <> 0 Then
Exit Function
End If
hnexthookproc = SetWindowsHookEx(2, AddressOf MyKBHFunc, App.hInstance, 0)
If hnexthookproc <> 0 Then
EnableKBDHook = hnexthookproc
End If
End Function
Private Sub Command1_Click()
EnableKBDHook
End Sub
Private Sub Command2_Click()
UnHookKBD
End Sub
Public Function MyKBHFunc(ByVal iCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
MyKBHFunc = 0
If iCode < 0 Then
MyKBHFunc = CallNextHookEx(hnexthookproc, iCode, wParam, lParam)
Exit Function
End If
If wParam = vbKeyReturn Then
Debug.Print "haha"
Else
Call CallNextHookEx(hnexthookproc, iCode, wParam, lParam)
End If
End Function
Private Sub Form_Load()
EnableKBDHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
CallUnHookKBD
End Sub
the problem is underline point.
|
|
|
|
|
Does the function reside in a DLL?
I are Troll
|
|
|
|
|
Can someone tell me why I would receive the following incode error: "
Expression is a value and therefore cannot be the target of an assignment"
Dim i, j As Integer
Dim xlapp As Excel.Application
Dim xlsht As Excel.Worksheet
Dim rng As Excel.Range
xlapp = New Excel._ExcelApplication
xlapp.DisplayAlerts = False
xlapp.Workbooks.Add()
xlsht = CType(xlapp.Sheets(1), Excel.Worksheet)
xlsht.Name = "BDIS Data Download"
Dim dc As DataColumn
Dim dr As DataRow
For i = 0 To gridContract.Columns.Count - 1
xlsht.Cells(1, i + 1) = gridContract(i).ColumnName
rng = CType(xlsht.Cells(1, i + 1), Excel.Range)
rng.Font.Bold = True
Next
For i = 0 To gridContract.rows.count - 1
For j = 0 To gridContract.Columns - 1
xlsht.Cells(i + 2, j + 1) = gridContract.rows(i)(j)
Next
Next
|
|
|
|
|
xlsht.Cells(1, i + 1) set a range object. you cannot assign it a value by using =
To set the range, the value you are trying to set, must be within the (...)
|
|
|
|
|
Simple. xlsht.Cells(...) returns a Range object, not a Value property.
|
|
|
|
|
Can't you just change
xlsht.Cells(1, i + 1) = gridContract(i).ColumnName
to
xlsht.Cells(1, i + 1).Value = gridContract(i).ColumnName
?
|
|
|
|
|
Thank you. I did make this correction.
|
|
|
|
|
SEND IT ON MY MAIL ID pollinedsac@gmail.com
|
|
|
|
|
|
rahuldsac wrote: WHERE WILL I GET VB.NET PROJECT
The magic fairies at the bottom of your garden, perhaps.
rahuldsac wrote: SEND IT ON MY MAIL ID pollinedsac@gmail.com
No, you did not use the magic word !!!
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
YOU HAVE TO GO TO THE TOP OF A VERY TALL BUILDING THEN JUMP OFF IT, THE RESULTANT SPEED WILL OPEN A PORTAL TO ANOTHER WORLD WHERE YOUR PROJECT IS WAITING FOR YOU
|
|
|
|
|
Lolz.......
|
|
|
|
|