offset while offset &ltlen(plaintext)chunk plaintext[offset:offset+chunk_sizeif len(chunkchunk_size ! chunk +(chunk_size len(chunk)encrypted +rsakey encrypt(chunkoffset +chunk_size encrypted encrypted encode("base "print "base encoded crypto%dlen(encryptedreturn encrypted def encrypt_post(filename)open and read the fil fd open(filename,"rb"contents fd read(fd close(encrypted_title encrypt_string(filenameencrypted_body encrypt_string(contentsreturn encrypted_title,encrypted_body our encrypt_post function is responsible for taking in the filename and returning both the encrypted filename and the encrypted file contents in base -encoded format we first call the main workhorse function encrypt_string passing in the filename of our target file which will become the title of our blog post on tumblr the first step of our encrypt_string function is to apply zlib compression on the file before setting up our rsa public key encryption object using our generated public key we then begin looping through the file contents and encrypting it in -byte chunkswhich is the maximum size for rsa encryption using pycrypto when we encounter the last chunk of the file if it is not bytes longwe pad it with spaces to ensure that we can successfully encrypt it and decrypt it on the other side after we build our entire ciphertext stringwe base -encode it before returning it we use base encoding so that we can post it to our tumblr blog without problems or weird encoding issues now that we have our encryption routines set uplet' begin adding in the logic to deal with logging in and navigating the tumblr dashboard unfortunatelythere is no quick and easy way of finding ui elements on the webi simply spent minutes using google chrome and its developer tools to inspect each html element that needed to interact with it is also worth noting that through tumblr' settings pagei turned the editing mode to plaintextwhich disables their pesky javascript-based editor if you wish to use different servicethen you too will have to figure out the precise timingdom interactionsand html elements that are required -luckilypython makes the automation piece very easy let' add some more codedef random_sleep()time sleep(random randint( , )return def login_to_tumblr(ie)retrieve all elements in the document full_doc ie document all iterate looking for the login form