Add hmacKey config field for video signing

This commit is contained in:
Zed
2019-10-24 00:17:38 +02:00
parent a56f217074
commit e91e7bcc1e
6 changed files with 18 additions and 9 deletions

View File

@@ -1,8 +1,11 @@
import strutils, strformat, sequtils, uri, tables
import nimcrypto, regex
var hmacKey = "secretkey"
const
key = "supersecretkey"
badJpgExts = @["1500x500", "jpgn", "jpg:", "jpg_"]
badPngExts = @["pngn", "png:", "png_"]
twitterDomains = @[
"twitter.com",
"twimg.com",
@@ -10,11 +13,12 @@ const
"pbs.twimg.com",
"video.twimg.com"
]
badJpgExts = @["1500x500", "jpgn", "jpg:", "jpg_"]
badPngExts = @["pngn", "png:", "png_"]
proc setHmacKey*(key: string) =
hmacKey = key
proc getHmac*(data: string): string =
($hmac(sha256, key, data))[0 .. 12]
($hmac(sha256, hmacKey, data))[0 .. 12]
proc getVidUrl*(link: string): string =
let