>>>
Zero-fill right shift Shifts right, but always fills in with 0's.

解决方案 »

  1.   

    String bintoascii(byte bySourceByte[])
            {
                int len1,i;
                byte tb;
                char high,tmp,low;
                String result;
                len1=len(bySourceByte);
                for(i=0;i<len1;i++)
                {
                    tb=bySourceByte[i];
                    
                    tmp=(char)((tb>>>4)&0x000f);
                    if(tmp>=10)
                        high=(char)('a'+tmp-10);
                    else
                        high=(char)('0'+tmp);
                    result+=high;
                    tmp=(char)(tb&0x000f);
                    if(tmp>=10)
                        low=(char)('a'+tmp-10);
                    else
                        low=(char)('0'+tmp);
                    
                    result+=low;
                }
                return result;
            }
      

  2.   

    #include<string>
    #include<iostream>
    #include<stdio.h>using namespace std;string bintoascii(char bySourceByte[])
    {
        int len,i;
        char tb;
        char high,tmp,low;
        len=strlen(bySourceByte);
        string result;
        
        for(i=0;i<len;i++) {
            tb=(char)bySourceByte[i];
            tmp=(char)((tb>>4)&0x000f);
            
            if(tmp>=10) {
                high=(char)('a'+tmp-10);
            } else {
                high=(char)('0'+tmp);
            }
            
            result+=high;
            tmp=(char)(tb&0x000f);
            
            if(tmp>=10) {
                low = (char)('a'+tmp-10);
            } else {
                low = (char)('0'+tmp);
            }
            
        result+=low;
    }
        return result;
    }int
    main(int args, char *argv[])
    {
        if (args < 2) {
            cout<<"Usage: md5 string"<<endl;
            exit(0);
        }
        cout<<bintoascii(argv[1])<<endl;
    return 0;
    }不知道行不行
      

  3.   

    我用java试过了那个bintoascii就是为了输出字符的ascii码啊
    md5的函数代码可以看看吗?