nodejs 參數進行字典序排序並md5或 sha1加密

1.參數字典序排序

名詞解釋:字典序排序也就是字段按照英文字母表的順序來排列
舉個栗子 token、timestamp、nonce三個參數進行字典序排序

 const token = 'msm123xyld'
       let str = [Token, Timestamp, Nonce].sort().join('')

2.對排序的字符串加密

1⃣️md5加密

    const result = crypto.createHash('md5').update(a).digest('hex')

2⃣️sha1加密

    const result = crypto.createHash('sha1').update(a).digest('hex')

來自一名菜鳥的自述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章