Example #1
0
    def content(self):
        '''writes beautiful blog entries'''
        pimages = self.image_pelic()
        images = self.existing_images()
        tagifaces = str()
        imageblock = str()

        for iface in images:
            tagifaces += '%s-%s, ' %(self.gatename, iface)
            imageblock += POSTIMAGES.format(
                gateway=self.gatename, iface=iface,
                filedate=self.date.filedate(), imgfile=pimages[iface]
            )

        content = POSTCONTENT.format(
            gateway=self.gatename, ifaces=tagifaces, date=self.date.date(),
            year=self.date.year(), month=self.date.month(), day=self.date.day()
            ).lstrip() + imageblock

        if self.rcmdout:
            rcmdlist = self.rcmdout.keys()
            for rcommand in sorted(rcmdlist):
                rcblock = str()
                for rcline in self.rcmdout[rcommand].split('\n'):
                    rcblock += '\n\t%s' %(rcline)
                content += POSTCOMMAND.format(command=rcommand, commandoutput=rcblock)

        if len(images) == 0:
            message('no images for %s [%s] found. skipping' %(self.gatename, self.date.date()), level=False)
            return
        return content
Example #2
0
 def __init__(self, gateway, wrkdate):
     if getgatelist()[gateway]:
         self.gate = getgatelist()[gateway]
         self.gatename = gateway
         self.date = wrkdate
         self.rcmdout = None
     else:
         raise Exception('wrong names.Dates object')
     msg = 'current gate: %s' %(gateway)
     message(msg)
     message('.' * len(msg))
Example #3
0
def parse_wrkday(args):
    '''creates a Dates object with content from args entry'''
    if 'a' in args.ar:
        year = TODAY.year if args.y == 0 else args.y
        month = TODAY.month if args.m == 0 else args.m
        day = TODAY.day if args.d == 0 else args.d
    else:
        year = TODAY.year - args.y
        month = TODAY.month - args.m
        day = TODAY.day - args.d
    try:
        wrkday = TODAY.replace(year, month, day)
    except ValueError as ex:
        message('invalid entry: %s' %(ex), level=False)
    else:
        message('valid date: %s' %(wrkday), shout=True)
        return Dates(wrkday)
Example #4
0
from helper import e_vigenere,int_to_text,text_to_int,e_Rsa,d_Rsa,message,divide_blocks

message1 = "shivamjadhavisahandsomeman"

key = "kerboros"

encrypted_message1 = message(e_vigenere(message1,key))

# user_publickey = "pi"
usernum = 1
rusername = 2
f = open("user_publickey.txt","r")
contents = f.read()
f.close()
list_of_keys = contents.split(" ")

user_num = text_to_int(list_of_keys[2*usernum-1])
name = "user"+str(usernum)+ "priv"+".txt"
f = open(name,"r")
contents = f.read()
l = contents.split(" ")
f.close()
user_privatekey = l[0]
rpublic_key = list_of_keys[2*rusername-2]
rnum = text_to_int(list_of_keys[2*rusername-1])

#print(list_of_keys[2*usernum-1],user_privatekey)
#print(rpublic_key,list_of_keys[2*rusername-1])
num = min(user_num,rnum)
cipher = []
key_cipher = []
Example #5
0
def main():
    '''the main'''
    message('main called')

    args = arg_parser()
    wrkday = parse_wrkday(args)

    if wrkday:
        for gate in getgatelist().keys():
            gtn = Names(gate, wrkday)

            if not args.nonet:

                if wrkday.date() == Dates(date.today()).date():
                    message('this is today, say cheese', shout=True)
                    message(gtn.snapshot(), shout=True)
                    message(gtn.remotecommands(), shout=True)
                message('trying to load graph', shout=True)
                message(gtn.getsnapshot(), shout=True)

            message('writing article', shout=True)
            gtn.mkpost()

        message('feeding the pelican', shout=True)
        mkpelican()

        message('all done', shout=True)
Example #6
0
 def __postinit(self):
     '''init afterparty'''
     msg = 'current scope: %s' %(self.date())
     message(msg)
     message(':' * len(msg))
Example #7
0
for i in c_k:
    k_prime = k_prime + i
cipher1 = divide_blocks(m_prime, num)
key_cipher1 = divide_blocks(k_prime, num)

pre_cm = []
pre_ck = []
final_cipher = ""
final_key = ""
for i in range(0, len(cipher1)):
    pre_cm.append(
        int_to_text(e_Rsa(int_to_text(cipher1[i]), spublic_key, snum)))
    # print(i,pre_cm[i])
    final_cipher = final_cipher + pre_cm[i]
    # print(int_to_text(cipher1[i]),int_to_text(d_Rsa(pre_cm[i],"xbrgadq",snum)))
for i in range(0, len(key_cipher1)):
    pre_ck.append(
        int_to_text(e_Rsa(int_to_text(key_cipher1[i]), spublic_key, snum)))
    # print(i,pre_ck[i])
    # print(int_to_text(key_cipher1[i]),int_to_text(d_Rsa(pre_ck[i],"xbrgadq",snum)))
    final_key = final_key + pre_ck[i]

# print(final_key)

t = message(d_vigenere(final_cipher, final_key))
# print(t)
if t == orignal_message:
    print(t)
else:
    print("REJECTED")