Microsoft has his way to lure XP users to use the latest version of its operating system. According to news posted at CNET, the software giant is building a "Windows XP mode" and was confirmed by Scott Woodgate (Leads product manager for Microsoft) on his blog. Windows XP mode uses Virtual PC technology to allow the new Windows 7 to easily run applications supported for Windows XP. Although the feature is not yet included on the BETA version of Windows 7, it is expected to be realesed with the upcoming release candidate version.
Update: According Adrian Kingsley-Hughes of ZDNET, the Windows 7 Release Candidate build (build 7100) has been leaked ahead of an official release by Microsoft.
According to the blog,
All you need to do is to install applications directly in Windows XP Mode which is a virtual Windows XP environment running under Windows Virtual PC. The applications will be published to the Windows 7 desktop and then you can run them directly from Windows 7
Windows XP Mode and Windows Virtual PC for Windows 7 Professional and Windows 7 Ultimate will soon be release in BETA. For the meantime you can view actual screenshots of the XP mode on this site
Update: According Adrian Kingsley-Hughes of ZDNET, the Windows 7 Release Candidate build (build 7100) has been leaked ahead of an official release by Microsoft. Read the full article here.
Most of my images are hosted on Picasa for free, just today a comment from my How to embed picasa sideshow entry made me create this post. Although for me, Picasa is a great tool and its free, the fact that visitors clicking the embeded images to make it bigger automatically redirected to picasa's website. So the question is, can we prevent this? the answer... Yes we can. If found this FancyZoom script last year but I don't feel that I need to implement it on my site so I just bookmarked it for future reference.
To install the FancyZoom script (made by Cabel) on your Blogger:
1. Download the FancyZoom package 2. Upload it on any free hosting server (if you are using blogger's ftp service, you can upload it on your blogger account) 3. Log into blogger, then goto Layout>Edit HTML 4. Add the following code before </head> tag
Next week, we are to migrate our existing Truckscale system that was developed in Visual Basic 6.0. The system talks to a Weight Indicator hardware unit that transmit Weight information from the Weigh bridge. Aside from the Truck weight, the system also accepts some other information like the plate number, driver and etc. But the only challenge we are facing here is the migration of the serial port com module. Luckily for us Serial Port integration with .NET 2.0 is easier than we expect because it has SerialPort Class that represents a serial port resource. Today, I will share the solution with you. So without further ado, here is how to implement serial port communication using C#:
To reference SerialPort class on your project, we need the following "Using" directives:
using System.IO; using System.IO.Ports;
Before we can communicate with a serial port, first we need to initialize it. Here's how:
Instantiate the Serial Port Class
//create an Serial Port object SerialPort sp = new SerialPort(); //Error handling SerialError spErr;
} catch (IOException ioex) { MessageBox.Show("Error opening device:" + ioex.Message, "Warning"); } catch (Exception ex) { MessageBox.Show("Error initializing device:" + ex.Message, "Warning"); } finally { //Bind the events on the following event handler sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); sp.ErrorReceived += new SerialErrorReceivedEventHandler(sp_ErrorReceived);
} }
Then to handle data being sent we need to put the data parsing code in sp_DataReceived event while for error handling use the sp_ErrorReceived event. To give you an idea, take a look on the actual code we have on our system:
//Serial Port DataReceived Handler private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e) { // This method will be called when there is data waiting in the port's buffer
// Determine which mode (string or binary) the user is in if (Settings.Default.DataMode == DataMode.Text) { // Read all the data waiting in the buffer try { string rawdata = sp.ReadLine();
//check if rawdata is empty if (rawdata.Length > 0) { //perform data format, strip non-numeric char starting from weigh unit string data = Convert.ToInt32(StripNonNumeric(rawdata.Substring(0, rawdata.IndexOf(Settings.Default.WeightUnit)))).ToString("##,##0") + Settings.Default.WeightUnit.ToLower(); if (data.Length > 0) { string preformat = data.Replace(",", ""); string weigh = preformat.Substring(0, preformat.IndexOf(Settings.Default.WeightUnit.ToLower())); //store weigh as string and int wd = new Weighdata(weigh, Convert.ToInt32(weigh)); // Display the text to the user in the terminal Log(data); //this just display the capture wieght on a textbox } }
} } else { // Obtain the number of bytes waiting in the port's buffer int bytes = sp.BytesToRead;
// Create a byte array buffer to hold the incoming data byte[] buffer = new byte[bytes];
// Read the data from the port and store it in our buffer sp.Read(buffer, 0, bytes);
// Show the user the incoming data in hex format Log(ByteArrayToHexString(buffer)); } }
Usually Weigh Indicator units are set to continuous data transmission so we need a Timer Control to capture the data being sent every second. Add a timer control and on its Tick event, paste the following codes:
private void tmrCheckDevice_Tick(object sender, EventArgs e) { //check if serial port is already open, if not initialize it. if (sp.IsOpen == false) {
//reconnect this.Text = "Truck Scale Entry (Disconnected from the device...)"; InitializeComPort();
switch (spErr) { case SerialError.Frame: statusmsg("The hardware detected a framing error."); break; case SerialError.Overrun: statusmsg("A character-buffer overrun has occurred. The next character is lost."); break; case SerialError.RXOver: statusmsg("An input buffer overflow has occurred. There is either no room in the input buffer..."); break; case SerialError.RXParity: statusmsg("The hardware detected a parity error."); break; case SerialError.TXFull: statusmsg("The application tried to transmit a character, but the output buffer was full."); break; } }
Simple huh?. You just need to remove or change the code to fit your needs. Thank you for reading and have a nice day!
According to Cyber Secure Institute, Since October 2008, the Conficker worm has been the center of a great deal of attention and debate. To date, the Conficker worm has already infected computers ranging from 200,000 to more than 10 million. It has also demonstrated the ability to both end run security measures and establish communications with controlled computers despite major efforts. It has also consumed an extraordinary amount of time and energy by CIOs and cybersecurity experts from around the world.
Cyber Secure Institute claims that based on their previous studies into the average cost of such malware attacks, the economic loss due to the Conficker worm could be as high as $9.1 billion. The research excludes an important fact though - not only is Conficker still active and infecting, but also, according to the most recent infection rate estimate courtesy of the Conficker Working Group, the number of infected hosts is 3.5 million. Here are the details of the analysis:
Any analysis of the true impact of Conficker must also factor in the (wasted) time, resources, and energies of the cyber-community, governments, companies and individuals. Extrapolating out from studies on the average cost of similar past attacks, the total economic cost of this worm (including the cost of efforts to combat the worm, the cost of purchasing counter-measure software) could be as high as $9.1 billion. Even using the single, outlying data source that suggests a much more limited scope of infection (greater than 200,000)—vastly less than all other sources suggest—the cost of this virus is still roughly $200 million dollars. It should, however be emphasized that these estimates do not factor in opportunity costs—just what could have been achieved if the expertise, time, energy and resources that have been devoted to combating this virus had been devoted to more productive efforts.
Since my site is contains article about programming. I often post sample sourcecode, XML and HTML scripts. My previous dilemma was, I can't simply copy and paste the codes directly to blogger editor because it will translate all entities enclosed with greater & less than sign such as <element>. The simplest way to do it is to encode the XML/HMTL code first using encoder tools which are available online. Here's a step-by-step procedure:
Google will start sending invitations to selected testers of their new offering called the Youtube RealTime. It lets you and your friends share in the moment what you're doing with the site. Those lucky testers will get 25 invitations of their own like with the one Gmail launched years ago that made it popular by viral marketing. RealTime allow users to see which of their friends are currently online, the videos they’re watching, and comments they wrote.
RealTime updates will be displayed in a top toolbar like the one by blogger.com on this site (look at the top) so users will see them every time. Now as you browse through YouTube, you'll get constant status updates as your friends stumble across cool videos then you’re going to want to see for yourself, and then your other friends will see an update alerting them about the video, creating an endless loop. Sound more viral huh?
On this next security article I will try to explain the HOW of XML encryption and decryption on VB.NET. The good thing about Microsoft's implementation of XML encryption is that it's W3C compliant. It means that you can exchange data with other implementations with ease. The full sourcecode for this article can be downloaded from here.
There are multiple types of encryption we can select from but for this example I will use Triple DES. Other encryption types are:
AES 128
AES 192
AES 256
RSA
X509CertificateEx
To avail of the .NET encryption, we need to include the following namespaces on our VB.NET project:
Visual Studio 2005 has an issue on System.Security.Cryptography.Xml. Framework 2.0 does not recognize such namespace. I personally don't know the reason behind the compiler's error but there is always a workaround. Just add a reference to System.Security in your project.
For this project, we will use the following XML document named as "sample.xml" (also include on the downloaded project files):
<purchase>
<items> <item quantity="1">XML Encrpytion on .NET</item> <item quantity="1">XML Encrpytion on .NET Workshop</item> <item quantity="1">Visual Studio 2005 Team Edition</item> </items>
<shipping> <buyer>Fryan Valdez</buyer> <streetaddress>319 Joseph St. Annex 41</streetaddress> <cityaddress>Manila</cityaddress> <country>Philippines</country> <zipcode>1772</zipcode> </shipping>
Here is the VB.NET Code to encrypt the element. Please read the comments (in green) carefully for the detailed description of each line. You can put this code on your Encrypt button like the one included on the downloadable project.
Dim xmldoc As New XmlDocument()
Try xmldoc.Load("sample.xml") 'Load XML Dim tDESkey As New TripleDESCryptoServiceProvider()
'Create the shared key and save it to disk to enable the receiver to decrypt Dim sharedkey As New TripleDESCryptoServiceProvider() Dim writer2 As IO.StreamWriter = New IO.StreamWriter("sharedsampleKey.txt") Dim str As String = Convert.ToBase64String(sharedkey.Key) writer2.WriteLine(str) writer2.Close()
Dim exml As EncryptedXml = New EncryptedXml(xmldoc)
'Select the XML node/element to be encrpyted Dim encryptElement As XmlElement = CType(xmldoc.SelectSingleNode("/purchase/billing"), XmlElement)
'Encrypt the XML element data using the TripleDES alogrithm and save the results into a byte array Dim encryptXML As Byte() = exml.EncryptData(encryptElement, sharedkey, False)
' Create an EncryptedData object and populate it. Dim ed As New EncryptedData() ed.Type = EncryptedXml.XmlEncElementUrl ed.EncryptionMethod = New EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl) ' Create a CipherData element and replace the current text value of element we want to encrypt ed.CipherData = New CipherData() ed.CipherData.CipherValue = encryptXML EncryptedXml.ReplaceElement(encryptElement, ed, False)
'Save the encrypted version of XML to disk xmldoc.Save("encryptedsample.xml")
Catch ex As Exception MessageBox.Show(ex.Message) End Try
The encryption code will create two files: 1. sharedsampleKey.txt - need by the recipient for decryption 2. encryptedsample.xml - the encrypted XML file
Here is the sample file (encryptedsample.xml) after encryption:
<purchase> <items> <item quantity="1">XML Encrpytion on .NET</item> <item quantity="1">XML Encrpytion on .NET Workshop</item> <item quantity="1">Visual Studio 2005 Team Edition</item> </items> <shipping> <buyer>Fryan Valdez</buyer> <streetaddress>319 Joseph St. Annex 41</streetaddress> <cityaddress>Manila</cityaddress> <country>Philippines</country> <zipcode>1772</zipcode> </shipping> <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"> <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlen c#tripledes-cbc" /> <CipherData> <CipherValue>rdUGco9lxMEP4A/uTh6lvrb6aZbQxXIAYcGnfsuzbl NNuDMYw6FpLA5oYgyRjfiwVJ0sv9rmtHpO6sBjCpF9Y5paOh0 /ViEeQp4ZLFHWRrFQ/5oKfPnOrIrX42ewfxrfe2Rsbe cAyuaetyHM7IF05gZkhr /OZC7/d2fBDASjInX8Vk/OquiV5Cr388l7H80r9fyHtk1qdmCUPqdpyN /IPhRFfxXmHhYzhcFpVppLjzUXiO91129qFTBH3E+M+LS5WeQFlI wYfptqDEz35Ez263lfoySqSampY76 +pg7LSOW54ZNIal1M0o0RSaacBU0JiaIh0HiYEWaw /S/Fpn5Sv46smq1m2Gm4BOAhQq /BVXs7+7MxPJN+ynBUsAqTL15+gti0r277um3ySgjpXJvpItq7 PHt+NlyEqfbIq1aUW5w=& lt;/CipherValue> </CipherData> </EncryptedData> </purchase>
You can notice that the billing element now contains encrypted values.
To decrypt the file (usually the recipient application will do this), use the following code:
Try Dim sharedkey As New TripleDESCryptoServiceProvider()
'Retrieve shared key and assign to the TripleDESCryptoServiceProvider object Dim rd As IO.StreamReader = New IO.StreamReader("sharedsampleKey.txt") Dim bytedata() As Byte = Convert.FromBase64String(rd.ReadToEnd()) sharedkey.Key = bytedata
Dim encryptedDoc As New XmlDocument() encryptedDoc.Load("encryptedsample.xml")
' XmlElement object. Dim EncryptedElement As XmlElement = CType(encryptedDoc.GetElementsByTagName("EncryptedData")(0), XmlElement)
' Create an EncryptedData object and populate it. Dim ed As New EncryptedData() ed.LoadXml(EncryptedElement)
' Decrypt the element using the attached shared key Dim encryptXML As New EncryptedXml() Dim decryptedXML As Byte() = encryptXML.DecryptData(ed, sharedkey)
' Replace the encryptedData element with the original text value. encryptXML.ReplaceData(EncryptedElement, decryptedXML) encryptedDoc.Save("decryptedsample.xml") Catch ex As Exception MessageBox.Show(ex.Message) End Try
Take note that the decryption method needs the "sharedsampleKey.txt" to decrypt the encrypted XML file. Decryption code will create a new file named as "decryptedsample.xml". It contains the original content without encryption.
You can download the full sourcecode of the project at mediafire
Since 1970, Every April 22 we celebrate Earth Day to inspire awareness and appreciation of our Mother nature. It was founded by U.S. Senator Gaylord Nelson as an environmental teach-in in 1970 and is celebrated in many countries every year. Upon reading on several tech news this morning, I found some nice videos ideas that use technology to save energy and help the environment. These may not be yet commercialize but I know having the kind of technology will greatly help Earth's environment, so kudos to people whos using their talent for greater good
Water Powered Car?
How about Air Powered Car?
One way or another mankind will have to find a way to heal deteriorating Mother Earth. Happy Techie Earth Day!
One type of authentication that we can use on our application is using the Windows Domain Account Authentication which we can achieve by using Lightweight Directory Access Protocol. On my previous project, we used an LDAP C# class to implement a Single Sign-On authentication. Single Sign-On means that all applications either web or desktop shares a single database of user accounts and that is the active directory users. To employ LDAP authentication on your own project, just download the complete C# class at mediafire.
The C# LDAP Class uses the System.DirectoryServices namespace to perform Active Directory search. See the code below:
//Update the new path to the user in the directory. _path = result.Path; _filterAttribute = (String)result.Properties["cn"][0]; } catch (Exception ex) { returnval = false; ErrDesc = "Error authenticating user. " + ex.Message; }
return returnval; }
IsAuthenticated function searches for a domain user inside a specific Domain. You just have to compile this class to build the DLL and call it from VB.NET or ASP.NET as shown below:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim son As New SingleSignOn()
son.LDAP_Path = "LDAP://yourdomain"
If son.IsAuthenticated("yourdomain", TextBox1.Text, TextBox2.Text) Then 'Parameters:Domain, Username, Password Label1.Text = "User is authenticated!" Else Label1.Text = "User is invalid! -- " & son.ErrDesc End If
End Sub
End Class
I also included a sample VB.NET project using the C# LDAP class. You can download it here.
If you love movies on ancient history like Gladiator starred by Russel Crow, definitely you will like the new feature from Google Earth, the Ancient Rome 3D. Its the virtual time machine which can be used to study the history of Rome and other great cities of the world. If you currently have Google Earth, you can Fly into Rome as it looked in 320 A.D. Enjoy visiting ancient Rome and navigate around the structures. You can also go into them, and enter areas like the Colosseum and even the Roman Senate.
Here are some screen shots taken from Google Earth Rome.
There are times that we have to implement file tampering detection on some file that we receive to verify its authenticity. On this article I will try to show you how to do it in VB.NET
First we need the following namespaces for file handling and hash computation:
For Beginner's sake, here is the definition of Cryptography namespace:
System.Security.Cryptography namespace provides cryptographic services, including secure encoding and decoding of data, as well as many other operations, such as hashing, random number generation, and message authentication.
To continue the article, On your VB.NET Project, Add two textboxes that will handle both the original file and the file being compared. It should look like something below:
Where: 1st File = Original File 2nd File = File being check if tampered
Then on the Test button, Put the following code:
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click Dim myHash As HashAlgorithm
myHash = HashAlgorithm.Create() 'Check if there are selected files If txt1stFile.Text <> String.Empty And txt2ndFile.Text <> String.Empty Then 'Open Original file using IO Dim fs1 As New FileStream(txt1stFile.Text, FileMode.OpenOrCreate) Dim fs1Bytes As Byte() = New Byte(fs1.Length) {} fs1.Read(fs1Bytes, 0, fs1.Length) Dim arr1() As Byte = myHash.ComputeHash(fs1Bytes) fs1.Close() 'Open 2nd File (the file being check for tampering) Dim fs2 As New FileStream(txt2ndFile.Text, FileMode.OpenOrCreate) Dim fs2Bytes As Byte() = New Byte(fs2.Length) {} fs2.Read(fs2Bytes, 0, fs2.Length) Dim arr2() As Byte = myHash.ComputeHash(fs2Bytes) fs2.Close()
'Compare using Bit Converter If BitConverter.ToString(arr1) = BitConverter.ToString(arr2) Then MessageBox.Show("The file is good.", "Hash Test") Else MessageBox.Show("The file was tampered.", "Hash Test") End If
Else MessageBox.Show("Please specify both 1st and 2nd files.", "Required Fields", MessageBoxButtons.OK)
End If End Sub
To test if the function is working, try to edit the 2nd file using Text Editor then recompare it again. The application should tell you that the file has been tampered. The most important line on this code was:
Dim arr1() As Byte = myHash.ComputeHash(fs1Bytes)
The function ComputeHash returns Hash values that will use by the program to compare the two files. Using this method, you can compare large plain text files or binary files without converting it first to string.
You can download the full project including test files you can use at mediafire. You can use the test files on \testfiles folder, It contains plain text, xml and binary files.
The Ubuntu team made the latest available for download of general use. According to Ubuntu creators, the final version of this release candidate will be ready on April 23rd, 2009. Here are some new features since Ubuntu 8.10:
GNOME 2.26
Brasero, version 2.26.0, as an all-in-one CD burning application
For testing only! This is a pre-release version of Ubuntu and is almost ready for general use. If it is important that your computer run reliably please continue to use the current stable release (8.10) until this version is ready on April 23rd, 2009.
This is my 4th installment of Blogger Tips on using Blogger.com. Some of your readers might want to subscribe only for topics under particular Label or Category. You can do this by using the following URL feed:
http://yourblog.blogspot.com/feeds/posts/default/-/Label Name
Just replace "yourblog.blogspot.com" with your blog address and "Label Name" with the particular label you want to create the feed from. An example of the final address should look like this:
Microsoft Search Server 2008 Express is a freeware from microsoft the enable intranet search capablities on your intranet file servers, exchange public folders, websites and etc. Search Server is a counterpart of Google Search Appliance. Its advantage is, you don't have to buy a piece of hardware and it's free. Here are some features you can expect from this search appliance: