Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792446
rabbitmq.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
rabbitmq.py
View Options
# -*- coding: utf-8 -*-
# -------------------------------------------------------------
# Salt — RabbitMQ execution module
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Allow to use RabbitMQ management plugin HTTP API
# License: BSD-2-Clause
# -------------------------------------------------------------
import
base64
import
hashlib
import
secrets
# -------------------------------------------------------------
# Credentials
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
compute_password_hash
(
password
):
salt
=
secrets
.
randbits
(
32
)
return
_compute_password_hash_with_salt
(
salt
,
password
)
def
_compute_password_hash_with_salt
(
salt
,
password
):
"""Reference: https://rabbitmq.com/passwords.html#computing-password-hash"""
salt
=
salt
.
to_bytes
(
4
,
"big"
)
# salt is a 32 bits (4 bytes) value
m
=
hashlib
.
sha256
()
m
.
update
(
salt
)
m
.
update
(
password
.
encode
(
"utf-8"
))
result
=
salt
+
m
.
digest
()
return
base64
.
b64encode
(
result
)
.
decode
(
"utf-8"
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Feb 28, 20:13 (33 m, 48 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2440642
Default Alt Text
rabbitmq.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment