2018-03-09 16:09:33 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
def toCidr(ip,mask=False):
|
|
|
|
""" Convert to CIDR notation
|
|
|
|
ip can be like this : 192.168.5.100/255.255.255.0
|
|
|
|
or you can provide the ip and the mask
|
|
|
|
"""
|
|
|
|
from IPy import IP
|
|
|
|
try:
|
|
|
|
if mask:
|
|
|
|
data="{0}/{1}".format(ip,mask)
|
|
|
|
else:
|
|
|
|
data=ip
|
|
|
|
return str(IP(data))
|
|
|
|
except:
|
|
|
|
return data
|
2018-03-19 14:35:00 +01:00
|
|
|
|
|
|
|
def readPass(encoder,reader):
|
|
|
|
try:
|
|
|
|
mypwdreader=open(reader, "r").readline().rstrip()
|
|
|
|
if encoder == "":
|
|
|
|
return mypwdreader
|
|
|
|
elif encoder == "base64":
|
|
|
|
import base64
|
|
|
|
return base64.b64encode(mypwdreader)
|
|
|
|
|
|
|
|
except:
|
|
|
|
return "mot de passe inconnu"
|