data=f.readframes(numframes) frames2=[ord(c) for c in data] framecount=44; length=0 key= raw_input("Enter the key:") base=math.ceil(math.log((((numframes*4)-44)/8) , 2)) #getting the length of message encoded for j in range(0,int(base)): length=length + (2**j) *(frames2[framecount] & 1 ) framecount = framecount + 1 count=0 K=rc4.keyarray(length*8, key) #rc4 random key generation using the input key #getting the message upto message length for i in range(0,length): number=0 for j in range(0,8): number=number + (2**j) *(bit.getbit(frames2[framecount],K[count]) ) framecount = framecount + 1 count=count+1 print (chr(number) , end="") print ("\n")
frames=[ord(c) for c in data] msg= raw_input("Enter the message:") key= raw_input("Enter the key:") integerrep=[ord(c) for c in msg] framecount=44; length=len(msg) base=math.ceil(math.log((((numframes*4)-44)/8) , 2)) #encoding message length to frames for j in range(0,int(base)): frames[framecount]=bit.changeLSB(frames[framecount],bit.getbit(length,j)) framecount=framecount+1 K=rc4.keyarray(length*8, key) #rc4 random key generation using the input key #encoding message upto message length count=0 for i in range(0,length): for j in range(0,8): frames[framecount]=bit.changeBIT(frames[framecount],K[count],bit.getbit(integerrep[i],j)) framecount=framecount+1 count=count+1 output=[chr(c) for c in frames]