/**?
*? SHA 1? Security encryption algorithm?
*? @param? Map? Parameter key value mapping set?
*? @ Return?
*? @throws? DigestException?
*/?
Public? Static electricity String? SHA 1 (map < string, object >? Map)? Throwing? DigestException? {?
//Get information summary? -? Parameter dictionary sort string?
String? Decryption? =? GetOrderByLexicographic (map); ?
Try it? {?
//specify sha 1 algorithm?
MessageDigest? Digestion? =? message digest . getinstance(" SHA- 1 "); ?
digest . update(decrypt . getbytes()); ?
//Get byte array?
Bytes? Message summary []? =? digest . digest(); ?
//? Create? Black magic? String?
StringBuffer? hexString? =? New? string buffer(); ?
//? Byte array converted to? Hexadecimal counting
For what? (int? Me? =? 0; ? Me? & lt? messageDigest.length? i++)? {?
String? shaHex? =? integer . tohexstring(message digest[I]? & amp? 0x ff); ?
What if? (shaHex.length()? & lt? 2)? {?
hex string . append(0); ?
}?
hex string . append(shaHex); ?
}?
Return? hexString.toString()。 toupper case(); ?
}? Catch? (NoSuchAlgorithmException? e)? {?
e . printstacktrace(); ?
Throw? New? DigestException ("Wrong signature!" ); ?
}?
}?
/**?
*? Get the parameters of dictionary sorting?
*? @param? Map? Parameter key value mapping set?
*? @ Return? String? Sort string?
*/?
Private? Static electricity String? GetOrderByLexicographic (map< string, object & gt? Map) {?
Return? split params(lexico graphic recorder(getParamsName(maps)),maps); ?
}?
/**?
*? Get the parameter name? Keys?
*? @param? Map? Parameter key value mapping set?
*? @ Return?
*/?
Private? Static electricity List & lt string & gt? getParamsName(Map & lt; String, object >? Map) {?
List & lt string & gt? paramNames? =? New? ArrayList & lt string & gt (); ?
For (figure. Entry & lt string, object & gt? Getting started? :? maps.entrySet()){?
param names . add(entry . getkey()); ?
}?
Return? paramNames?
}?
/**?
*? Parameter names sorted by dictionary?
*? @param? paramNames? Parameter name list set?
*? @ Return? List a set of sorted parameter names?
*/?
Private? Static electricity List & lt string & gt? Dictionary recorder (List & lt string & gt? paramNames){?
collections . sort(param names); ?
Return? paramNames?
}?
/**?
*? Parameter names and values after splicing and sorting?
*? @param? paramNames? Sorted set of parameter names?
*? @param? Map? Parameter key value mapping set?
*? @ Return? String? Spliced strings?
*/?
Private? Static electricity String? split params(List & lt; String & gt? ParamNames, Map< string, object & gt? Map) {?
StringBuilder? paramStr? =? New? StringBuilder(); ?
For (string? paramName? :? paramNames){?
paramstr . append(param name); ?
For (figure. Entry & lt string, object & gt? Getting started? :? maps.entrySet()){?
if(param name . equals(entry . getkey()){?
paramstr . append(string . value of(entry . getvalue())); ?
}?
}?
}?
Return? paramstr . tostring(); ?
}