Analysis of msnobj in MSN Protocol

Source: Internet
Author: User
Msnobj information is displayed in the MSN Messenger communication.
For example:
> Chg 140 NLN 805306468% 3 cmsnobj % 20 creator % 3d % 22 XXXX % 40hotmail.com % 22% 20 size % 3d % 2233630% 22% 20 Type % 3d % 223% 20 LOCATION % 3d % 22tfr7. dat % 22% 20 friendly % 3d % 22aaa % 3d % 22% 20sha1d % 3d % 22fup1qsbeahwv3ifgjmglklt % 2fc5k % 3d % 22% 20sha1c % 3d % 22B % 3d % 22% 2f % 3E

The URL code that follows is actually msnobj.
After urldecode is used, we can see the actual content.
<Msnobj creator = "xxxxx@citiz.net" size = "24588" type = "3" location = "tfr73.dat" friendly = "AAA =" sha1d = "TF/zg8 + rfqik3ymrvo2dzq0afgs =" sha1c = ""piz9dywnxhtddw5pd/qtkcbw99i ="/>

There are some elements in msnobj, so you can see what is going on.
Size refers to the file size, location is the file name, and friendly is fixed. I am also studying it.
Type is a type description, 3 is the Avatar, and others may represent emotion and so on. sha1d and sha1c will be explained later.
After obtaining your <msnobj> from the other's MSN Messenger, you will know that your MSN profile information will initiate a P2P request.

Sha1d is the digital digest of your file. It reads all the bytes of the tfr73.dat file and then implements SHA-1.AlgorithmTo obtain a 20-byte stream, and then encode it with base64.
Sha1c is the result of numerical summarization of various element strings in msnobj.

Based on this principle, we can easily program and implement sha1d and sha1c.
Try {
// Get an object of SHA-1
Java. Security. messagedigest alga = java. Security. messagedigest. getinstance ("SHA-1 ");

// Read File byte stream
File F = new file ("tfr73.png ");
Int Len = (INT) F. Length ();
Fileinputstream Fi = new fileinputstream (f );

Byte [] Buf = new byte [Len];
Fi. Read (BUF );
Fi. Close ();

// Create sha1d Value
Alga. Update (BUF );
Byte [] digesta = alga. Digest ();
String sha1d = base64.encodebytes (digesta );

// Create sha1c Value
Stringbuffer sb = new stringbuffer (50 );
SB. append ("creator ");
SB. append ("enhydraboy_robot01@citiz.net ");
SB. append ("size ");
SB. append (LEN );
SB. append ("type ");
SB. append (3 );
SB. append ("location ");
SB. append ("tfr73.dat ");
SB. append ("friendly ");
SB. append ("AAA = ");
SB. append ("sha1d ");
SB. append (sha1d );

Alga. Update (sb. tostring (). getbytes ());
Digesta = alga. Digest ();
String sha1c = base64.encodebytes (digesta );
System. Out. println ("sha1d = \" "+ sha1d + "\"");
System. Out. println ("sha1c = \" "+ sha1c + "\"");

} Catch (exception e ){
E. printstacktrace ();
}

The result is as follows:
Sha1d = "TF/zg8 + rfqik3ymrvo2dzq0afgs ="
Sha1c = "piz9dywnxhtddw5pd/qtkcbw99i ="

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.