![]() ![]() |
Mar 11 2008, 09:21 PM
Post
#16
|
|
![]() From Atlantis to Interzone Group: Global Moderators Posts: 2,512 Joined: 23-February 06 From: Somewhere in space and time Member No.: 65 |
Here's a simple script I wrote to open a text file, increment all the letters in it by two and save them to another text file:
CODE import sys
import string in_file = open("encrypt", "r") text = in_file.read() in_file.close() def increment(char, by=2): return chr(ord(char)+by) out_text = "" for char in text: if char.isalpha(): if char.startswith(("y","z","Y","Z")): out_text = out_text + increment(char, -24) else: out_text = out_text + increment(char) else: out_text = out_text + char out_file = open("py.out", "w") out_file.write(out_text) -------------------- Holy shit, pebkac, you're awesome! "Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." - Theodor Seuss Geisel (AKA Dr. Seuss) "An idea that is not dangerous is unworthy of being called an idea at all." - Oscar Wilde |
|
|
|
Mar 11 2008, 10:17 PM
Post
#17
|
|
![]() Group: Members Posts: 10,620 Joined: 23-February 06 From: Houston, TX Member No.: 48 |
This could be a fun thread
CODE using System.IO;
class Program { static void Main() { StreamReader sr = new StreamReader("inputfile.txt"); StreamWriter sw = new StreamWriter("outputfile.txt"); foreach (char c in sr.ReadToEnd()) { sw.Write((char)((int)c+1)); } sw.Close(); } } |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 19th December 2025 - 11:40 PM |