Skip to content

Instantly share code, notes, and snippets.

View SubChord's full-sized avatar

Thijs van der Burgt SubChord

View GitHub Profile
package net
import (
"errors"
"fmt"
"net/http"
"sync"
)
type Broker struct {
@SubChord
SubChord / SASService.java
Last active July 24, 2018 13:06
Generate SAS tokens for Azure.
private String generateSASToken(String uri, String deviceKey, String policyName, Long expiry) {
String token = null;
try {
Long epoch = System.currentTimeMillis() / 1000L;
Long ttl = epoch + expiry;
String toSign = String.format("%s\n%d", URLEncoder.encode(uri, "utf-8"), ttl);
String signature = new String(hmac256Encode(deviceKey, toSign));
String skn = "";