Found 35163 Articles for Programming

Python Function to Check UNIX Passwords

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

497 Views

To verify UNIX password, we should use the crypt module. It has crypt(3) routine. It is basically one-way hash function based on the modified DES algorithm. To use the crypt module, we should import it using. import crypt Method crypt.crypt(word, salt) This method takes two arguments. The first one is the word and second one is salt. The word is basically the user password, which is given in the prompt. The salt is a random string. It is used to perturb the DES Algorithm in one of 4096 ways. The salt contains only Upper-case, Lower-case, Numeric values ... Read More

Access to the Group Database in Python

George John
Updated on 25-Jun-2020 14:03:37

197 Views

To access the UNIX group database, we should use the grp module. The shadow password database entries are like tuple like object.To use the grp module, we should import it using −import grpThe attributes of the grp database are −IndexAttribute & Description0gr_nameThe Name of the groups1gr_passwdThe Encrypted password for the group. (Generally empty)2gr_gidThe group id (Numeric)3gr_memA list of group usersIn the group object, the gid is an integer. The group name and the password are strings. The Member list is a list of strings.Some methods of this module are −Method grp.getgrgid(gid)This method will return group database entry from the given ... Read More

Access to the Shadow Password Database in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

198 Views

To access the UNIX shadow password database, we should use the spwd module. We need enough privileges to access this file. The shadow password database entries are like tuple like object. To use the spwd module, we should import it using − import spwd The attributes of the shadow password database are − Index Attribute & Description 0 sp_nam The Login Name or the username of the user 1 sp_pwd The Encrypted password 2 sp_lstchg Date of last change 3 sp_min Minimal number of days ... Read More

Access to the Password Database in Python

Ankith Reddy
Updated on 25-Jun-2020 14:04:13

427 Views

To access the password database, we should use the pwd module. Using this module, we can access users account and password database. The password database entries are like tuple like object.To use the pwd module, we should import it using.import pwdThe attributes of the password database are −IndexAttribute & Description0pw_nameThe Login Name or the username of the user1pw_passwdThe Encrypted password2pw_uidNumeric ID for the user3pw_gidNumeric ID for the user’s group4pw_gecosName of the user and comment field5pw_dirHome directory of the user6pw_shellUser’s Command interpreter.Note − Generally, the pw_passwd holds the encrypted passwords. But in the new systems, they use the shadow password system. ... Read More

The most Common POSIX System Calls in Python

Arjun Thakur
Updated on 25-Jun-2020 14:04:38

623 Views

The posix module is works on the UNIX environment. It provides the Operating system functionality.We should not import this module directly. We can use the os module. The os module is acts as a superset of the posix module on UNIX. On non-Unix system the posix is not available, but the os is available with some less functionality.To use the posix module, we should import it using.import posixThere are different methods and constants in the POSIX module.Constant posix.environThe environ is a dictionary object. It holds keys and values. The keys and values are of bytes type for UNIX. For example, ... Read More

Convenient Web-browser controller in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

747 Views

To display web based documents to users by using python, there is a module called webbrowser. It provides high level interface to handle web documents. On UNIX based system, this module supports lynx, Netscape, Mosaic etc browsers. For Windows and Macintosh, it uses the standard browsers. To use this module, we need to import the following module. import webbrowser The webbrowser module has different methods, and exceptions, these are as follows − Exception webbrowser.Error This error will raise when there is an error in the webbrowser interface. Method webbrowser.open(url, new=0, autoraise=True) This method is used to display the ... Read More

Generate Secure Random Numbers for Managing Secrets using Python

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

275 Views

To generate secure random numbers cryptographically we can use the secrets module in python. This module is helpful to create secure password, account authentication, security tokens or some related secrets. To use the classes and modules of the secrets module, we should import that module into our code. import secrets Random Numbers The secrets module is used to access some secure source of randomness. That is provided by the operating systems. Classes and functions, related to random numbers of the secrets modules are − Class secrets.SystemRandom It is a class to generate random numbers, by using some highest ... Read More

Secure Hashes and Message Digest in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

1K+ Views

For the secure hash and message digest process, we should use the hashlib module. This module implements a common interface for different secure hash algorithm like SHA1, SHA224, SHA256, SHA512 etc. Also the RSA’s MD5 algorithm. Older algorithms are known as the Message Digest and the new methods are called Secure Hash. To use this module, we need to import the hashlib module in the python code. import hashlib In this method, there are some predefined algorithms like md5, sha1, sha224, sha256, sha512 are present. We can add additional algorithms from the OpenSSL library. Some methods, constants of ... Read More

Support for Enumerations in Python

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

110 Views

In Python, Enumerations are implemented by using the enum module. The Enums has names and values. The Enums can be accessed by using names or values. To use this module, we should import it using. import enum The Enum has some properties. These are − Enums can be displayed as string or repr format. The type() method can display the enum types There is name keyword, to show names of the enum members. Enums are iterable Example Code Live Demo import enum class Rainbow(enum.Enum): VIOLET = 1 INDIGO ... Read More

Python Alternate repr() implementation

George John
Updated on 30-Jul-2019 22:30:23

292 Views

In Python, if we want to limit the large amount of data from displaying, we can use the reprlib module. To use this module, we should import it using. import reprlib There are different classes and methods related to reprlib. These are − Class reprlib.Repr The Repr class provides formatting services. It creates functions like built-in repr(). In this class we can add size limits and different object types. Method reprlib.repr(object) This method is used to return string like built-in repr() method, But in this case there is a limits on most sizes. Repr Objects The Repr object ... Read More

Advertisements