Great article. Gives some very valuable information on implementing sets with a finite universe.
It doesn’t suit my requirements – I need to represent sets where the universal set might be infinite – like, say the set of strings.
The trouble starts with trying to implement the set complement operation – you can’t obviously list an infinite set, so the trick is to represent it as a cofinite set. I haven’t really read up on cofinite sets, but the layman definition goes as
‘A set whose complement is finite’
Well that’s it. So keep a flag with the data structure to indicate a set complement.
The ElementOf operation is trivial to implement. Subset is trickier and so’s union, intersection and difference.
I just completed a bare bones implementation using a hashmap. All the tests are working (got 20 of them). You can find it here ifÂ you’re interested.
And now I need to roll out my own version of a set datastructure library. C# has hashmaps – they come close but aren’t really sets. You can use them to implement sets, but that’s about it. Also, I want my sets to conform to one of the standard collection interfaces so that they can interoperate with code. And I REALLY REALLY need set intersection, set union and set difference!
I’ve been looking on the net for some guidelines to implement the same – implementing a data structure is never easy so its better to be cautious to get it right. Just found this article which seems to fit the bill.
Visual C# Developer Center: Part 6: Efficiently Representing Sets
Hope this helps. Will post more on the article later.
I’ve this need to calculate a file fingerprint in VB6. So the need to access CrptoAPI in vb6. Didnt want to do win32 calls from VB and thankfully MS has a COM layer over cryptoAPI called CAPICOM. Useful stuff…as the MSDN site says
“Summary: CAPICOM is a new security technology from Microsoft that allows Microsoft Visual Basic, Visual Basic Script, ASP, and C++ programmers to easily incorporate digital signing and encryption into their application. (5 printed pages)”
Okay, now you can calculate SHA1, SHA-256 and SHA512 using VB. Trouble was that you cannot use the Filesystem object as it doesnt read binary files.
Here’s a small sample that does a SHA1 for binary files in VB6.
Const BUFFER_SIZE AsString= 4096
Dim sha As CAPICOM.HashedData
Set sha =New CAPICOM.HashedData
Open “somebinaryfile.xyz”For Binary As f
Dim totalbytes AsLong
Dim currentPos AsLong
currentPos = 0
While currentPos + BUFFER_SIZE <= totalbytes
Get f, , buffer
currentPos = currentPos + BUFFER_SIZE
Dim chunk() AsByte
Dim chunkSize AsLong
chunkSize = totalbytes - currentPos
If (chunkSize > 0) Then
ReDim chunk(1 To chunkSize)
Get f, , chunk
txtHash.Text = sha.Value
ASPAlliance.com : ASP and ASP.NET Tutorials : The LogonUser API
Finally found a way to allow ASPNET user access to the LogonUser api. Guess what, WinXP and above, no specific permissions are required! Cool.
I was trying out WSE2.0 SP2 Hands on lab on security and hit this really strange problem.
I needed to install the sample certificates supplied with WSE, typically located in C:\Program Files\Microsoft WSE\v2.0\Samples\Sample Test Certificates.
As given in the Hands on lab manual, I installed the Server Certificate.pfx (server’s private key) to the LocalMachine\Personal store and the Client Certificate.pfx (client’s private key) to the CurrentUser\Personal store. The trouble started when I wanted to install the Server’s public key to the Current User’s\Other People store as directed. There wasn’t an Other people Tab available in the mmc snap in. There is a workaround given in the Hands on lab manual –
Note: if you don’t have an Other People store under Current User, open Internet Explorer, select Tools, Internet Options, Content, and press the Certificates button. You should see an Other People tab in the certificates dialog. You can import the certificate here through this interface or you can return to mmc and refresh the Current User tree and Other People should now show up.
Trouble was, it didnt work for me. I never got the tab in MMC as the note says and nor was I able to import the certificate to the correct location.
After a bit of googling, turns out that you can use the certmgr.exe’s command line. It accepts a ‘-s’ argument used to specify the store – and the value required for ‘Other People’ store is “AddressBook”
So the command becomes
certmgr -add “Server Public.cer” -s AddressBook
and voila – works like a charm. You can then refresh MMC console and see that the certificate has indeed been imported successfully.
Am back today after a long time. Been down with viral fever and doing nothing more than warming the bed with my backside :(.Â Really depressing!
Anyway am back today – but feeling quite tired.
This thing’s thrown a spanner in the works in more than one thing – was supposed to go to the finale of the Aero India show here and couldn’t make it – thanks to the viral! Was hoping to snap some nice pics there – esp. of the Surya Kirans’ acrobatic show and post them on the blog…