JAVA代码示例

    public static String generateSignature(String deviceNo, String expires, String appSecret) throws NoSuchAlgorithmException {
        StringBuilder reversed = new StringBuilder(appSecret);
        String combinedString = deviceNo + expires + appSecret + reversed.reverse();

        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] hashBytes = digest.digest(combinedString.getBytes(StandardCharsets.UTF_8));

        String base64Hash = Base64.getEncoder().encodeToString(hashBytes);
        return URLEncoder.encode(base64Hash,StandardCharsets.UTF_8.toString());
    }
作者:mry  创建时间:2025-03-03 17:27
最后编辑:mry  更新时间:2025-04-02 14:04