Added funtions and code to secure.py