Skip to content

Commit

Permalink
修复方法命名错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sky130 authored Jul 20, 2024
1 parent 4f9dac2 commit 6d89b1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions miot-api/src/main/java/miot.kotlin/utils/DataUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import miot.kotlin.MiotManager.base64Encode

fun generateSignedNonce(secret: String, nonce: String): String {
val sha = MessageDigest.getInstance("SHA-256")
sha.update(base64Dcode(secret))
sha.update(base64Dcode(nonce))
sha.update(base64Decode(secret))
sha.update(base64Decode(nonce))
return base64Encode(sha.digest())
}

fun generateSignature(uri: String, signedNonce: String, nonce: String, data: String): String {
val sign = "$uri&$signedNonce&$nonce&data=$data".toByteArray(StandardCharsets.UTF_8)
val mac = Mac.getInstance("HmacSHA256")
mac.init(SecretKeySpec(base64Dncode(signedNonce), "HmacSHA256"))
mac.init(SecretKeySpec(base64Decode(signedNonce), "HmacSHA256"))
val digest = mac.doFinal(sign)
return base64Encode(digest)
}
Expand Down

0 comments on commit 6d89b1b

Please sign in to comment.