The ASCII thing can be explained simply with an example, as below:
How much do you want to shift your letters by?
35
What is your message?
hi
There's your problem. The problem with this code is that you don't enforce an ASCII range limit; so someone could, say, shift by 3500 characters and result in a strange, weird UTF8 mess. Even worse, you can shift by negatives:
How much do you want to shift your letters by?
-200
What is your message?
hi
Traceback (most recent call last):
File "t.py", line 11, in <module>
trashy(something, numbermove)
File "t.py", line 5, in trashy
message2= message2+chr(x+move)
ValueError: chr() arg not in range(0x110000)
The above value error is Pythons built-in Unicode enforcement; values converted with chr() must be within the range 0-1114112 (0x0-0x110000). However, that range, for the purposes of this cipher project, is far greater than what you need; a cipher that wraps around after it has reached the end of the ASCII table is fine enough. To solve this problem, determine if the ordinal of the character your scanning (and moving) results in an ordinal either greater than 126 or less than 32 (to avoid control characters.)
As for your other question: a byte rotation (also known as a circular shift) is a (easy to break, but fine for this purpose) algorithm where you have a list of (in this case) bytes (which, in the usual case, is in a tuple, but a string will suffice). In the algorithm, you take all the entries (bytes) in that tuple (string) and rearrange them such that the last entry (byte) in the tuple (string) is moved (rotated or shifted) to the first position and all other entries (bytes) are moved into the next sequential position in the tuple (string). So, take the string "hello". If you perform a circular shift on that string, o is moved (shifted) to the position of h, and h, e, l, and l are moved (shifted) such that they fill the remaining space of the string, thereby creating the string "ohell".
To aid you, I'll leave you with the following nugget of info: a circular shift (byte rotation) is a permutation s of the n bytes in the string such that either the sigma of i is identical to (i+1)%n, for all bytes i=1, n; or the sigma of i is identical to (i-1)%n, for all bytes i=1, n. The algorithm is repetitive, which I'll demonstrate twice below. If your implementation is correct, it should follow the following steps (though obviously this is heavily dependent on the string your passing it), assuming 'abcd' is your string:
* Input: abcd
* abcd becomes dabc
* input: dabc
* dabc becomes cdab
* input: cdab
* cdab becomes bcad
* input: bcad
* bcad becomes abcd (original input)
As such, if this is a homework assignment, and if your teacher uses the string "hello", and repeatedly applies your implementation to the string, something like the following should happen:
* teacher passes in "hello"
* "hello" becomes "ohell"
* "ohell" becomes "lohel"
* "lohel" becomes "llohe"
* "llohe" becomes "elloh"
* "elloh" becomes "hello" (original input)
Hope this helps!
"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." — Charles Babbage.
My Github