]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/mcrypt.py
Fix(setup): Fix keywords and platforms
[m_lib.git] / m_lib / mcrypt.py
index d6ae1dcd841670425f050af772938229bff1392b..13357371147af122e0f08d1880ff6295a95318b0 100755 (executable)
@@ -3,11 +3,9 @@
 #
 # useful function(s) for module crypt
 #
-# Author: Oleg Broytman <phd@phd.pp.ru>
-# Copyright (C) 1998-1999 PhiloSoft Design
-#
 
 
+from __future__ import print_function
 import random, crypt
 
 
@@ -28,6 +26,11 @@ def gen_salt():
 
 
 def test():
+   try:
+      raw_input
+   except NameError:  # Python 3
+      raw_input = input
+
    passwd = raw_input("Enter password: ")
    salt = gen_salt()
    encrypted = crypt.crypt(passwd, salt)
@@ -35,17 +38,16 @@ def test():
    pwd_file = open("test.pwd", 'w')
    pwd_file.write("%s:%s" % ("user", encrypted))
    pwd_file.close()
-   print "Password file written"
+   print("Password file written")
 
-   import string
    pwd_file = open("test.pwd", 'r')
-   username, encrypted = string.split(pwd_file.readline()[:-1], ':')
+   username, encrypted = pwd_file.readline()[:-1].split(':')
    pwd_file.close()
 
    if crypt.crypt(encrypted, encrypted):
-      print "Password verified Ok"
+      print("Password verified Ok")
    else:
-      print "BAD password"
+      print("BAD password")
 
 if __name__ == "__main__":
    test()