-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesthmac.py
More file actions
41 lines (29 loc) · 923 Bytes
/
testhmac.py
File metadata and controls
41 lines (29 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import hashlib
username = "testuser1"
realm = "matchflix"
password = "testpass1"
# Create the input string
input_str = f"{username}:{realm}:{password}"
# Generate the MD5 hash
hmac = hashlib.md5(input_str.encode()).hexdigest()
print(hmac)
# import hmac
# import hashlib
# import base64
# import time
# def get_turn_credentials(name, secret):
# # Calculate UNIX timestamp for 24 hours from now
# unix_timestamp = int(time.time()) + 24 * 3600
# username = f"{unix_timestamp}:{name}"
# # Create HMAC using SHA1
# hmac_obj = hmac.new(secret.encode('utf-8'), username.encode('utf-8'), hashlib.sha1)
# password = base64.b64encode(hmac_obj.digest()).decode('utf-8')
# return {
# "username": username,
# "password": password
# }
# # Example usage
# name = "testuser2"
# secret = "secretkey"
# credentials = get_turn_credentials(name, secret)
# print(credentials)