Skip navigation
All Places > PI Developers Club > Blog > 2012 > June
2012

After Rick's post I realized that there are still some code snippets I wanted to share with you. The following snippets will show you simple tasks you used to do with the PI SDK like creating a tag, writing data or signing up for events.

 

 

 

So let's start with connecting to the PI Server:

 
// the PI server
OSIsoft.AF.PI.PIServers myPIServers = new OSIsoft.AF.PI.PIServers();
OSIsoft.AF.PI.PIServer myPIServer = myPIServers.DefaultPIServer;
myPIServer.Connect();

As usual I am using my default server only to keep things simple

 

As Rick mentioned already - things are slightly different between AF SDK and PI SDK. So for the point attributes, AF SDK expects a dictionary:

 

 

 
string strSolution = "AFSDK_RDA_CodeSnippets";
Dictionary<string, object> myAttributes = new Dictionary<string, object>();
myAttributes.Add("CompMin", 0);          // CompMin 0
myAttributes.Add("CompMax", 600);        // CompMax 10 min
myAttributes.Add("CompDev", 60);         // CompDev 60
myAttributes.Add("Compressing", 1);      // Compressing on
myAttributes.Add("ExcMin", 0);           // ExceptionMin 0
myAttributes.Add("ExcMax", 0);           // ExceptionMax 0
myAttributes.Add("ExcDev", 0);           // ExceptionDeviation 0
myAttributes.Add("Pointsource", strSolution);

now we are ready to create the PI point:

 
OSIsoft.AF.PI.PIPoint myPIPoint = myPIServer.CreatePIPoint("myTagname", myAttributes);

Let us generate a list of values: 

 
List<OSIsoft.AF.Asset.AFValue> myValues = new List<OSIsoft.AF.Asset.AFValue>;
DateTime myTimeStamp = DateTime.Now.AddSeconds(-1000);
Random myRandom = new Random(myTimeStamp.Second);

for (int cc = 0; cc < 1000; cc++)
{
        myValues.Add(new OSIsoft.AF.Asset.AFValue(myRandom.Next(0, 100),
                                                  new OSIsoft.AF.Time.AFTime(myTimeStamp)));
        myTimeStamp = myTimeStamp.AddSeconds(1);
}

 and send them to PI:

 

myPIPoint.UpdateValues(myValues, OSIsoft.AF.Data.AFUpdateOption.Insert);

 

 A frequent topic for the PI SDK are the EventPipes. In the AF SDK we have this mechanism as well – the PIDataPipe. This time we are not looking for a single tag, we are getting a PointList:

 

OSIsoft.AF.PI.PIPointList myPIPoints = new OSIsoft.AF.PI.PIPointList(OSIsoft.AF.PI.PIPoint.FindPIPoints(myPIServer, "*", strSolution));

 

 Let us sign up for snapshot events:

 

OSIsoft.AF.PI.PIDataPipe myPIDataPipe = new OSIsoft.AF.PI.PIDataPipe(OSIsoft.AF.Data.AFDataPipeType.Snapshot);
myPIDataPipe.AddSignup(myPIPoints);

 

And for the rest of the day I keep watching events coming into my system:

 

long lValCount = 0;
while (Console.KeyAvailable == false)
{
    OSIsoft.AF.AFListResults<OSIsoft.AF.PI.PIPoint, OSIsoft.AF.Data.AFDataPipeEvent> myEvents;
    myEvents = myPIDataPipe.GetUpdateEvents(1000000);
    if (myEvents.Count > 0)
    {
        lValCount += myEvents.Count;
        Console.WriteLine("{0,7:N0} events ({1,10:N0}) ({2,8:N0} events/s).", 
                          myEvents.Count, 
                          lValCount, 
                          myEvents.Count/2.0);
    }
    System.Threading.Thread.Sleep(2000);
}

So - if you have not tried the new AF SDK 2.5 - go and download the beta and start exploring! 

To all PI Web Services users,
we are pleased to announce the immediate availability of the Community Technology Preview (CTP) of PI Web Services 2012!

 

This CTP is designed to give technical users a preview of PI Web Services 2012, providing you an opportunity to get acquainted with the new features, plan ahead for deployments, and share feedback around how to enhance the upcoming release. This version brings some significant new features that this community has been asking for:

  • Search for PI Asset Framework (PI AF) Elements and associated Attributes, leveraging your comprehensive asset model to improve the access to time-series data. This includes searches by name, template, location, Attribute names and values, etc.
  • Search for PI AF Element Templates
  • Search for PI Event Frames, including the ability to navigate to referenced elements and their Attributes to obtain time-series data

Please consult the User Manual (PDF or CHM) for more information on the new methods, objects, etc. You can also access the document in HTML format on your PI Web Services server, by browsing to http://yourServer/PIWebServices/Help (if you installed the IIS Edition, not the Standalone Edition).

 

As you would expect with a pre-release version, there are a few limitations and pieces of functionality that are missing - so here is a list of the enhancements that we expect to bring in the actual PI Web Services 2012 release:

  • Ability to write values to AF Attribute paths (the InsertPIData method currently only supports writing to PI Point paths)
  • Retrieval of PI Event Frames statistics, such as the total time covered, average/minimum/maximum length, and the count
  • [Ability to retrieve time-series data for PI Event Frame Attributes directly (the CTP only supports retrieving time-series data for Attributes belonging to AFEelements referenced by PI Event Frames)
    ***UPDATE: in fact this is possible with the CTP version. See the first and third entries in the comments below, for more details.***
  • Search for AF Element Attributes directly, without going through their parent Element
  • Ability to use the GetPIArchiveData method to request interpolated time-series data by time interval (StartTime, EndTime, TimeStep), in addition to requesting it by number of interpolations (StartTime, EndTime, NumInterval)
  • PIEventFrame.Duration, returned by the FindPIEventFrames method, will return the elapsed time at the time of the query for Event Frames that are still running (the CTP version returns null)
  • Consolidation of the PI Event Frames types in a single XML namespace: http://xml.osisoft.com/services/PIEventFramesService (some objects are in http://xml.osisoft.com/services/EventFrames at this point)

Keep in mind this is a pre-release version and as such, shouldn't be used in a Production environment - please refer to the OSIsoft vCampus End-User License Agreement for more details about CTP-specific licensing terms.

 

The PI Web Services product team looks forward to hearing from you! Please submit your feedback on the discussion forum or privately to BetaPIWebServices@osisoft.com

Continuing my look into the imminent release of AF 2.5 with RDA, today’s topic will look at the new Summary method in AFSDK. Though AF 2.5 has gone through 2 CTP releases and 1 Beta, bear in mind that the current AF 2.5 code base is still Beta and could be subject to change before its production release in 2012Q3.

 

The Summary method is nothing new for PISDK users. But thanks to the Rich Data Access of AF 2.5, AF Attributes – not just PI Points – will have a much anticipated Summary method. There are a many differences between what the two SDK’s offer, sometimes subtle and sometimes not subtle at all.

 

Let’s take a brief look at some differences before showing the code examples:

 

What is returned?

 

PISDK returns a solitary PIValue for one summary type of one PI Point for one time range.
AFSDK returns an IDictionary object for one or more summary types for one AF Attribute for one time range. The key to the dictionary is the summary type and its value is an AFValue object.

 

The PercentGood associated with the summary

 

PISDK sticks this in a ValueAttributes property of the returned PIValue.
AFSDK includes it, upon request, as an additional Summary type to be returned.

 

b>How times are specified

 

PISDK expects two parameters for StartTime and EndTime as Objects.
AFSDK expects one AFTimeRange parameter.

 

What gets summarized?

 

PISDK obviously only works for PI Point objects.
AFSDK could work for any AF Attribute if the data reference supports the method.

 

A Difference with Count

 

PISDK the Count will produce a Double.
AFSDK the Count will produce an Integer.

 

A Difference with Average

 

PISDK the Average could throw an exception if there are no recorded values in the time range.
AFSDK the Average won’t throw an exception; however the Average (i.e. AFValue.Value) will either be a Double with a good status OR a String with a bad status.

 

Let’s take a look at some examples to give you a hint of possibilities. The AFSDK examples won’t focus on just tag centric, i.e. PI Point data references, but rather for any AF Attribute. The first 2 examples contrast PISDK to AFSDK, and the 3rd example is AFSDK only.

 

Example 1 – PISDK Count

 
        // Produce an event weighted Count for a PISDK PIPoint
        public static void PISDK_SummaryExample1(PISDK.PIPoint tag, object StartTime, object EndTime)
        {
            // Convention of -1 denotes unknown Count
            int iCount = -1;
            PISDK.PIValue pv = null;
            // Count will be a Double.
            pv = tag.Data.Summary(StartTime, EndTime, ArchiveSummaryTypeConstants.astCount, CalculationBasisConstants.cbEventWeighted);
            iCount = Convert.ToInt32((double)pv.Value);
            Console.WriteLine("PI Point '{0}' has {1} recorded events from {2} through {3}", tag.Name, iCount, StartTime, EndTime);
        }

Example 1 – AFSDK Count

 
        // Produce an event weighted Count for an AFSDK Attribute
        public static void AFSDK_SummaryExample1(AFAttribute attribute, object StartTime, object EndTime)
        {
            // Convention of -1 denotes unknown Count
            int iCount = -1;
            // Safe Practice: first check that the data method is supported
            if ((attribute.SupportedDataMethods & AFDataMethods.Summary) == AFDataMethods.Summary)
            {
                // Merge StartTime and EndTime objects into one timeRange
                AFTimeRange timeRange = new AFTimeRange(new AFTime(StartTime), new AFTime(EndTime));
                // Prep a IDictionary object to hold initial result 
                IDictionary summary = null;
                summary = attribute.Data.Summary(timeRange, AFSummaryTypes.Count, AFCalculationBasis.EventWeighted, AFTimestampCalculation.Auto);
                // Trivial Check: make sure returned IDictionary object has the intended summary key
                if (summary.ContainsKey(AFSummaryTypes.Count))
                {
                    // The Count is returned as an Integer
                    AFValue pv = summary[AFSummaryTypes.Count]; 
                    iCount = (int)pv.Value;
                }
            }
            Console.WriteLine("Attribute '{0}' has {1} recorded events from {2} through {3}", attribute.Name, iCount, StartTime, EndTime);
        }

Example 2 – PISDK Average

 

          // Produce a time weighted Average for a PISDK PIPoint
        public static void PISDK_SummaryExample2(PISDK.PIPoint tag, object StartTime, object EndTime)
        {
            double dAverage = double.NaN;
            try
            {
                PISDK.PIValue pv = null;
                // The Average will either be returned as a Double, OR an exception will be thrown.
                pv = tag.Data.Summary(StartTime, EndTime, ArchiveSummaryTypeConstants.astAverage, CalculationBasisConstants.cbTimeWeighted);
                // If execution reaches this point, pv is valid and pv.Value is a Double.
                dAverage = (double)pv.Value;
            }
            catch (Exception e)
                {
                    // No Operation.  The exception message is "Calculation failed."
                    // Ignore it and accept default dAverage of double.NaN
                }
            Console.WriteLine("PI Point '{0}' has an average of {1} from {2} through {3}", tag.Name, dAverage, StartTime, EndTime);
        }

Example 2 – AFSDK Average

 
         // Produce a time weighted Average for an AFSDK Attribute
        public static void AFSDK_SummaryExample2(AFAttribute attribute, object StartTime, object EndTime)
        {
            double dAverage = double.NaN;
            // Safe Practice: first check that the data method is supported
            if ((attribute.SupportedDataMethods & AFDataMethods.Summary) == AFDataMethods.Summary)
            {
                // Merge StartTime and EndTime objects into one timeRange
                AFTimeRange timeRange = new AFTimeRange(new AFTime(StartTime), new AFTime(EndTime));
                // Prep a IDictionary object to hold initial result 
                IDictionary summary = null;
                summary = attribute.Data.Summary(timeRange, AFSummaryTypes.Average, AFCalculationBasis.TimeWeighted, AFTimestampCalculation.Auto);
                // Trivial Check: make sure returned IDictionary object has the intended summary key
                if (summary.ContainsKey(AFSummaryTypes.Average))
                {
                    // The Average (pv.Value) will be returned either as a Double,
                    // OR have a bad status with value = "[-11059] No Good Data For Calculation"
                    AFValue pv = summary[AFSummaryTypes.Average];
                    // One way to only grab a good number
                    if ((pv.Status & AFValueStatus.QualityMask) == AFValueStatus.Good)
                    {
                        dAverage = (double)pv.Value;
                    }
                    //// Another way to only grab a good number
                    //if (pv.Value is double)
                    //{
                    //    dAverage = (double)pv.Value;
                    //}
                }
            }
            Console.WriteLine("Attribute '{0}' has an average of {1} from {2} through {3}", attribute.Name, dAverage, StartTime, EndTime);
        }

Example 3 – AFSDK with Multiple Summary Types

 
         // AFSDK Summary allows multiple summary types over entire time range.  
        // Produce summary of event-weighted Count and PercentGood.
        public static void AFSDK_SummaryExample3(AFAttribute attribute, object StartTime, object EndTime)
        {
            int iCount = -1;
            double dPctGood = double.NaN;
            if ((attribute.SupportedDataMethods & AFDataMethods.Summary) == AFDataMethods.Summary)
            {
                AFTimeRange timeRange = new AFTimeRange(new AFTime(StartTime), new AFTime(EndTime));
                IDictionary summary = null;
                summary = attribute.Data.Summary(timeRange, AFSummaryTypes.Count | AFSummaryTypes.PercentGood, AFCalculationBasis.EventWeighted, AFTimestampCalculation.Auto);
                if (summary.ContainsKey(AFSummaryTypes.Count))
                {
                    AFValue pv = summary[AFSummaryTypes.Count];
                    iCount = (int)pv.Value;
                }
                if (summary.ContainsKey(AFSummaryTypes.PercentGood))
                {
                    AFValue pv = summary[AFSummaryTypes.PercentGood];
                    dPctGood = (double)pv.Value;
                }
                Console.WriteLine("Attribute '{0}' has {1} recorded events with {2}% good from {3} through {4}", attribute.Name, iCount, dPctGood, StartTime, EndTime);
            }
        }

That’s at least some early attempts at some code. I wish I had time and space to post VB equivalents but I barely have time at work to even squeak this blog out. For those of you who haven't had a time to dive too deeply into AF 2.5, I at least wanted to give you a heads up on some new features.

OSIsoft vCampus had the opportunity to host a hackathon during the Connected World Conference in St. Charles, Ill (near Chicago). To quickly explain the setup: there were three companies providing a hackathon track: OSIsoft, Exosite and ILS Technology. Contestants had 36 hours to compete in the challenge, and come up with an awesome new application build using the tools provided. They were competing for nice prizes (1st: $3000, 2nd: $1500, 3rd: iPad)

 

I arrived in Chicago on Saturday, and had a day to stay awake and fight the jetlag. I took a cab to the Pheasant run resort, and was amazed by the country side we passed. Big buildings in the middle of nowhere, a huge drive in cinema and a lot of parking spaces everywhere! Mind you, I'm from the Netherlands, and we usually have to fight to get a parking space near the 'big' cities. The resort itself was pretty awesome, and the weather was really nice (about 30 deg. Celcius, 86 deg Fahrenheit, 303 deg Kelvin). After taking the Sunday to do some final preperations, we had the hackathon kickoff at the 'Hackathon Pavilion'.

 

We prepared an infrastructure, with a PI System deployed 'in the cloud' using Skytap. Participants received an USB drive with PI Client software, Data Access Products, manuals and documentation and off course code samples.

 

4263.IMG_5F00_5813.JPG

 

The participants were OSIsoft customers, partners, OSIsoft employees (mainly TechSupport and Field Service) and two students from Northwestern University. Soon, teams  formed, and after having our introduction and some pizza, we headed of to our room to start our 36 hour hackathon.

 

2742.IMG_5F00_5868.JPG

 

You could feel the energy of programmers working on something creative immediately after we started.  The degree of experience of each participant was highly variable, from years of experience to ’What is the PI System?’ The first evening was taken to get people up to speed on the PI System and the different PI Data Access tools. Our primary focus for this hackathon was using PI Web Services and AF SDK 2012 (CTP) technologies. People unfamiliar with PI AF SDK 2012 were pretty excited about the new capabilities.

 

During the night, a lot of people were still working late. At about 3 am Stuart decided to go to Wallmart to get some extra refreshments and a waffle iron. This lead to some hilarity because I wouldn't believe Wallmart was open 24 hours a day (we don't have that here). So, after Stuarts return he started making waffles, and soon the whole room started to smell like a small bakery.

 

0143.IMG_5F00_5873.JPG

 

At about 4 am I went to bed, but a lot of people stayed up late. The two students from Northwestern didn't sleep at all. When I came back the same morning - after my morning swim - they were still at it! Later that morning, Dr. Kennedy (the founder of OSIsoft) presented a talk about Lit San Leandro that a couple of people went to. It was a very interesting talk about the effort to put in a fiber optics ring in the city to attract new business in a former industry town. Dr. Kennedy later came and visited us at our room to get to know the people and inquire about the different projects. 

 

7360.IMG_5F00_5842.JPG

 

During the rest of the day people were working hard to finish their projects. Stuart made some improvised home-made guacamole that night, and people enjoyed it while programming like crazy.

 

6786.IMG_5F00_5865.JPG

 

I went to bed a little early (about 1 am) to get some sleep for the following day. Wednesday was to be our closing session, we had a 4 hour session from 8 am - 12 am where people could finish their projects with the maximum assistance from OSIsoft people. After people finished the last hurdles, they were asked to present their project with their team. After careful deliberation a panel of judges awarded the prices. The judges were comprised of OSIsoft people, industry experts and people from Connected World. Let's have a look at the different teams and the projects they made!

 

1st Prize - Team Soap (Northwestern University)

 

7462.IMG_5F00_5901.JPG

 

Team Soap consisted of two students from Northwestern University. They named their team after the fact that they didn't sleep (or shower) for 2 days, and they had a big challenge connecting a SOAP web service to their Django (Python) environment. Their project consisted of connecting an Arduino to the PI System using a C# application, to feed information from the device into the PI System. From their they used Django (Python) to get data out of the PI System using PI Web Services to create a very slick HTML5 interface. They made it easy to connect different Arduino devices to the PI System and visualize the information in a dashboard. Before the hackathon started, they had never worked with the PI System. It was very impressive to see how much they have learned in that short amount of time. They won first prize with this project, and took home $3000!

 

2nd Prize - Team '3 guys, a gal and a PI System' (RoviSys)

 

2112.IMG_5F00_5891.JPG

 

RoviSys is a partner of OSIsoft, and they had 4 people at the hackathon! Their goal was to create a Event Frame generator using PI Notifications. They also created an HTML5 front-end that could display the Event Frames in a Gantt chart. I personally found this project particularly interesting. They found a great way to generate Event Frames. From a user perspective this is very interesting, because it requires no coding, only configuration of the Notification triggers. This is a great way of generating event frames, until we have the Event Frame Generator, or Configured Analytics to generate those event frames. The HTML5 interface was very responsive and quick. It displayed all the information related to the Event Frames in a clear way. With this outstanding project they won 2nd prize, and took home $1500!

 

Team Exele (James)

 

4645.IMG_5F00_5896.JPG

 

Team Exele (from Exele Information Systems) are also a partner of OSIsoft, and we had the pleasure of having James with us. James had an utmost creative idea! His project was to store Twitter messages in the PI System using Event Frames. He created a very nice and clean HTML interface, that allows users to submit a query. This query was then stored into an AF Element. A separate service than monitored the queries, and stored all Twitter messages related to that query in the PI System. This would allow you to store Twitter messages related to a particular subject for long periods of time (far beyond the history limit of Twitter). I would say this is especially nice for marketing, demographics and research. He also created a nice and clean interface to display the results, and pinpoint a message location on a map using Google maps. Team Exele won 3rd prize with this, taking home a brand new iPad!

 

We also had teams from OSIsoft participating. One particular team decided to participate in the Exosite track, by creating an interface between Exosite's OnePlatform and the PI System. They won 1st prize at the Exosite track with this. Very impressive, we will certainly follow up on this with the Exosite team!

 

5556.IMG_5F00_5906.JPG

 

Another team from OSIsoft created a prototype of a manual logging application with geolocation in HTML5. The application would use Google Maps to locate the assets closest to you, display them on the map, and give the user the opportunity to manually enter data. A great accomplishment, and I could certainly imagine a future for such a product! It was demonstrated on a laptop, an iPad and Android phones.

 

2350.IMG_5F00_5910.JPG

 

And, off course a picture of the whole group afterwards!

 

5078.IMG_5F00_5915.JPG

 

Looking back to the event, I found it a huge success. A lot of great initiatives were being developed. The energy and atmosphere during the hackathon were awesome. Thanks to everyone who helped out and participated! I really hope we get to do this more often. I can imagine something like this being done before or during vCampus Live! 2013 can be really interesting. What do you think? Please leave a comment below!

 

We have more material coming up, including videos and interviews with the participants. These need some processing, but we will be sure to post them as soon as possible!

 

 

 

 

 

 

Recently I've been working on setting up several environments for demonstrations and testing purposes. To get a bit of head start on setting up a realistic PI AF model. I got a couple of databases from others so these can be imported into the AF Server.

 

Having the elements and the associated template created in my database from imported .xml file is great but in some situation that I still have to ensure that the attributes are getting the correct information. For example, attributes with PIPoint data reference should be pointing to the right PI server. Sometimes, even if the template of the attribute is configured using substitution parameters like %Server%, representing the name of PI AF Server, you can still end up in situations where the attribute instance is still pointing to another PI Server. This is because data reference configuration on an attribute can be locked in. An example would be if you use the option to Create or Update PI Point. After that, any subsequent changes made to the template will not propagate to elements based on the template.

 

This is where Reset to Template is useful. As the name suggests, it 'resets' the attribute to utilize the setting of the template. In PI System Explorer, you can select an attribute and choose the option to "Reset to Template", but the problem we have is there is no option to do that in bulk.

 

An alternative to do this in one step is using PI AF Builder add-in in Microsoft Excel. While there is no Reset to Template option, what you can do is copy the config string from the Attribute Template and replace the config strings of derived attribute. This is essentially what happens in the background when you choose to Reset to Template in PI System Explorer. This works but it may still take some effort, because you have to export the list of elements and attributes, update the config string and then export them back to the AF database.

 

Another alternative would be to do this using AF SDK, from a simple program, or a Powershell script. In my case, I've created a Powershell script that loads OSIsoft.AFSDK.dll, find all derived elements from an element template and resets all their attributes. All you need to provide is the AF Server name, AF Database name and name of element template.

 

The key part of resetting the attribute to template settings is the following:

 

 

 

if($AFAttribute.Template)
{
    # * if the attribute have different data reference from the template, reset with template's data reference
    if($AFAttribute.Template.DataReferencePlugIn -ne $AFAttribute.DataReferencePlugIn)
    {
        $AFAttribute.DataReferencePlugIn = $AFAttribute.Template.DataReferencePlugIn
    }          
    # * if attribute's data reference is not null and attribute's config string is difference from template. reset with template's config string
    if($AFAttribute.DataReferencePlugIn)
    {
        if ($AFAttribute.ConfigString -ne $AFAttribute.Template.ConfigString)
        {
            $AFAttribute.ConfigString = $AFAttribute.Template.ConfigString 
        }
    }
    # * if attribute's data reference is null, resetting means taking the template's default value
    else
    {
        $AFAttribute.SetValue($AFAttribute.Template.GetValue($null), $null)
    }        
}

 

 

 

 

With the script, the amount of manual work to reset the attributes to template is minimized. You can download this powershell script. There are some consideration that I have not included in the script that you want to take note of:

  • The script retrieves the element template by name, so you have to correctly input the name.
  • The script doesn't take into account child attributes.

Hope this would help anyone who does AF Database migration!

Many vCampus members are active in other social media communities such as LinkedIn.  As such today's news about a massive breach of LinkedIn user accounts might affect you. It's time to change your password, right?

 

Probably right for most of us but surprisingly some security experts say not so fast.  How could this be good advice? 

 

One scenario assumes LinkedIn is totally pwned.  If true, changing your LinkedIn password is a waste of cycles (or worse if on reset you happen to expose a password that is used by your accounts elsewhere in cyberspace).

 

That being said, if your normal practice is to use a common password across certain web site genre it is a good idea to change those other passwords.  I'll confess, in my case, LinkedIn and Twitter were using the same password.  Yes, that practice is past tense as in dead and buried with Twitter sporting the new password.

 

As for my LinkedIn password, it is reset but not used elsewhere and assumed compromised until more details emerge. Certainly I expect we will learn more about the LinkedIn breach in the coming days.

 

In fact there is a bit more right now.  Unfortunately some poor security hygiene at LinkedIn has been reported. Apparently passwords are stored using a straight unsalted SHA1 hash. Hackers have posted millions of hashes on the web like a trophy.

 

Out of curiosity, I wanted to check if my password was cracked.  The first step was to compute the hash for my password.  While there are plenty of utilities like Microsoft Sysinternals Sigcheck that compute hashes for files, I failed to find one for a password. So here is a code snip that computes a hash for a given plaintext string:

 
Imports System
Imports System.Security.Cryptography
Imports System.IO
Imports System.Text

Public Module secaudit

Sub Main()

Dim data() As Byte
Dim sha1() As Byte
Dim pass As String = String.Empty

Call ReadPlainText(pass)
If pass.Length > 0 then

'Console.WriteLine("pass:" & pass)
data = Encoding.UTF8.GetBytes(pass)

Dim sha As New SHA1CryptoServiceProvider()
sha1 = sha.ComputeHash(data)

Dim sb As New StringBuilder(sha1.Length * 2) 
For Each b As Byte In sha1 
sb.Append(b.ToString("X02")) 
Next 

Console.WriteLine("SHA1:" & sb.tostring())
end if

End Sub

Sub ReadPlainText(byref pass as string)
Dim info As ConsoleKeyInfo

'use ReadKey for computing password hashes
Console.Write("Plaintext: ")
Do
    info = Console.ReadKey(True)
    If info.Key = ConsoleKey.Enter Then
        Exit Do
    Else
        pass &= info.KeyChar
        Console.Write("*"c)
    End If
Loop
Console.WriteLine()
End Sub
End Module

You really don't need to write code since this function is available on the web but it just didn't feel right to enter my password on a hacking web page.  Regardless, the very next place I went is to test the hash at a web site called md5decrypter.

 

The site has a fairly extensive set of tools. This form will allow you to compute hashes.  This one will check to see if the SHA1 hash has been decrypted.  Note, not all IT departments allow access to dual use hacking tools, such as those found at http://www.md5decrypter.co.uk.

 

If the hash is cracked on this site or not is a bit moot.  SHA1 is known to be insufficient for today's computing power and all LinkedIn passwords should be assumed compromised until more details are made public.  However, this exercise does help illustrate one benefit of choosing a good password!

 

PS. Curiosity killed the cat.  Indeed, my password was cracked.

 

Update1:  (forwarded from Paul Gusciora)

 

LinkedIn investigating reports that 6.46 million hashed passwords have leaked online (update) http://www.theverge.com/2012/6/6/3067523/linkedin-password-leak-online

 

 

 

Website http://www.leakedin.org/  will check if your password can be found on the list of stolen hashes. Bear in mind if you have a common password a positive result may not mean that your account has been compromised

 

 

 

Slashdot discussion:        LinkedIn Password Hashes Leaked Online

 

http://it.slashdot.org/story/12/06/06/1335228/linkedin-password-hashes-leaked-online

 

 Update2: http://www.leakedin.org/   <--- be sure to use an "i" not an "l" ; "i" is a legit site.

 

Update3: CNET is recommending https://lastpass.com/linkedin/
http://news.cnet.com/8301-1009_3-57449325-83/what-the-password-leaks-mean-to-you-faq/

 

 

Filter Blog

By date: By tag: