summaryrefslogtreecommitdiff
path: root/sbhs_server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'sbhs_server/helpers')
-rw-r--r--sbhs_server/helpers/__init__.py0
-rw-r--r--sbhs_server/helpers/__init__.pycbin0 -> 146 bytes
-rw-r--r--sbhs_server/helpers/mailer.py16
-rw-r--r--sbhs_server/helpers/mailer.pycbin0 -> 962 bytes
-rw-r--r--sbhs_server/helpers/simple_encrypt.py34
-rw-r--r--sbhs_server/helpers/simple_encrypt.pycbin0 -> 1113 bytes
6 files changed, 50 insertions, 0 deletions
diff --git a/sbhs_server/helpers/__init__.py b/sbhs_server/helpers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sbhs_server/helpers/__init__.py
diff --git a/sbhs_server/helpers/__init__.pyc b/sbhs_server/helpers/__init__.pyc
new file mode 100644
index 0000000..e4b1769
--- /dev/null
+++ b/sbhs_server/helpers/__init__.pyc
Binary files differ
diff --git a/sbhs_server/helpers/mailer.py b/sbhs_server/helpers/mailer.py
new file mode 100644
index 0000000..7c58f95
--- /dev/null
+++ b/sbhs_server/helpers/mailer.py
@@ -0,0 +1,16 @@
+from sbhs_server import settings
+import smtplib
+
+def email(to, subject, message):
+ smtpserver = smtplib.SMTP()
+ smtpserver.connect(settings.EMAIL_HOST, settings.EMAIL_PORT)
+ smtpserver.ehlo()
+ smtpserver.starttls()
+ smtpserver.ehlo()
+ smtpserver.esmtp_features['auth']='LOGIN DIGEST-MD5 PLAIN'
+ smtpserver.login(settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD)
+
+ header = 'To: ' + to + '\n' + 'From: ' + settings.EMAIL_HOST_USER + '@iitb.ac.in\n' + 'Subject: ' + subject +' \n'
+ msg = header + '\n' + message + '\n\n'
+ smtpserver.sendmail(settings.EMAIL_HOST_USER + '@iitb.ac.in', to, msg)
+ smtpserver.close() \ No newline at end of file
diff --git a/sbhs_server/helpers/mailer.pyc b/sbhs_server/helpers/mailer.pyc
new file mode 100644
index 0000000..5105102
--- /dev/null
+++ b/sbhs_server/helpers/mailer.pyc
Binary files differ
diff --git a/sbhs_server/helpers/simple_encrypt.py b/sbhs_server/helpers/simple_encrypt.py
new file mode 100644
index 0000000..976fe4d
--- /dev/null
+++ b/sbhs_server/helpers/simple_encrypt.py
@@ -0,0 +1,34 @@
+import base64
+
+def encrypt(cleartext):
+ string = cleartext
+
+ string = string[::-1]
+
+ for i in xrange(3):
+ string = base64.b32encode(string)
+ string = string[::-1]
+ string = string.lower()
+
+ padding = string.count("=")
+ string = string.replace("=", "")
+ return str(padding) + "." + string
+
+
+
+def decrypt(ciphertext):
+ data = ciphertext.split(".")
+ padding = int(data[0])
+ cipher = data[1]
+
+ for i in xrange(padding):
+ cipher = "=" + cipher
+
+ string = cipher
+
+ for i in xrange(3):
+ string = string.upper()
+ string = string[::-1]
+ string = base64.b32decode(string)
+
+ return string[::-1] \ No newline at end of file
diff --git a/sbhs_server/helpers/simple_encrypt.pyc b/sbhs_server/helpers/simple_encrypt.pyc
new file mode 100644
index 0000000..ffb331f
--- /dev/null
+++ b/sbhs_server/helpers/simple_encrypt.pyc
Binary files differ