44.Android Md5util
Public classMd5util { Public StaticStringgetmd5string(String key) {CharHexdigits[] = {' 0 ',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ',' 8 ',' 9 ',' A ',' B ',' C ',' D ',' E ',' F '};Try{byte[] input = Key.getbytes ();//MessageDigest object for MD5 algorithmMessageDigest md5digest = messagedigest.getinstance ("MD5");//ConversionMd5digest.update (input);//Cipher byte[] Md5byte = Md5digest.digest ();//String to hex intj = md5byte.length;CharMd5char[] =New Char[J *2];intK =0; for(byteB:md5byte) {md5char[k++] = hexdigits[b >>>4&0xf]; md5char[k++] = hexdigits[b &0xf]; }return NewString (Md5char); }Catch(Exception e) {E.printstacktrace ();return NULL; } }Private StaticStringbytestohexstring(byte[] bytes) {StringBuilder SB =NewStringBuilder (); for(byteabyte:bytes) {String hex = integer.tohexstring (255& Abyte);if(hex.length () = =1) {Sb.append (' 0 '); } sb.append (hex); }returnSb.tostring (); }}
44.Android Md5util