#!/usr/bin/python # -*- coding: utf-8 -*- from datetime import datetime import hashlib class Utilities: def convert_iso8601_to_readable(timestamp): old_date_format = datetime.fromisoformat(timestamp.replace("Z", "+00:00")) new_date_format = old_date_format.strftime("%B %d, %Y") return new_date_format def hash_url_to_md5(url): url_encoded = url.encode() url_hashed = hashlib.md5(url_encoded) url_digest = url_hashed.hexdigest() return url_digest def is_jid_matches_to_session(accounts, sessions, request): jabber_id = request.cookies.get('jabber_id') session_key = request.cookies.get('session_key') if (jabber_id and jabber_id in accounts and jabber_id in sessions and session_key == sessions[jabber_id]): return jabber_id