# Python 3, 130 bytes *Thanks to @Rod for pointing out a bug* from random import* def f(x):l=10**len(x);k=str(randint(0,l-1)+l)[1:];print(''.join(chr(ord(i)+int(j))for i,j in zip(x,k))+'\n'+k) A function that takes input via argument as a string and prints to STDOUT. **How it works** from random import* Import everything from the random module def f(x): Function with input string x l=10**len(x) Define l for later use as 10^length(x) randint(0,l-1)+l Generate a random integer in the range [0, l-1] and add l, giving a number with l+1 digits... k=str(...)[1:] ...convert to a string and remove the first character, giving a key of length l that can include leading zeroes, and store in k for i,j in zip(x,k) For each character pair i,j in x and k: chr(ord(i)+int(j)) Find the UTF-8 code-point (same as ASCII for the ASCII characters), add the relevant key digit and convert back to character ''.join(...) Concatenate the characters of the ciphertext print(...+'\n'+k) Add newline and key, then print to STDOUT [Try it on Ideone](http://ideone.com/NQhkiZ)