要求:经过URLEncoder.encode((msgData+timeStamp+checkWord),”UTF-8”)后进行MD5,最后在转换为Base64字符串
declare
v_req varchar2(4000) := '{"orderId":"KDDD2007777857000","customsInfo":{"orderName":"LMLKKDK413"},"cargoDetails":[{"name":"55寸LCD电视","unit":"台","count":1,"weight":12.5,"length":125,"width":45,"height":35},{"name":"65寸LCD电视","unit":"台","count":2,"weight":18.5,"length":145,"width":55,"height":45}],"contactInfoList":[{"contactType":1,"contact":"Test","tel":"13015924969","mobile":"13015924969","province":"广东省","city":"广州市","county":"越秀区","address":"东风东路776号"},{"contactType":2,"contact":"Test","tel":"13015924969","mobile":"13015924969","province":"广东省","city":"广州市","county":"海珠区","address":"江泰路地铁口"}],"monthlyCard":"7551234567","serviceList":[{"name":"INSURE","value":"300","value1":"1"},{"name":"COD","value":"300","value1":"9999999999"}],"payMethod":1,"parcelQty":1,"totalWeight":5.0,"isDocall":0,"isSignBack":1,"temperatureRange":0,"isOneselfPickup":0,"isReturnSignBackRoutelabel":1,"isReturnRoutelabel":1,"isUnifiedWaybillNo":0}166798089353318KB1KX7VLVI5OE6' ;
v_req_url varchar2(4000);
v_md5 varchar2(100);
v_64 varchar2(100);
begin
v_req_url := utl_url.escape(url => v_req,url_charset => 'UTF8',escape_reserved_chars => TRUE);
select MD5str(v_req_url) into v_md5 from dual;
select utl_raw.cast_to_varchar2(utl_encode.base64_encode(v_md5)) into v_64 from dual;
dbms_output.put_line(v_md5);
dbms_output.put_line(v_64);
end;
CREATE OR REPLACE FUNCTION MD5str(
passwd IN VARCHAR2)
RETURN VARCHAR2
IS
retval varchar2(32);
BEGIN
retval := utl_raw.cast_to_raw(DBMS_OBFUSCATION_TOOLKIT.MD5(INPUT_STRING => passwd)) ;
RETURN retval;--大小写转换
END;