Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34580
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vlastimil.brom@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; '"""': 0.05; 'skip:" 60': 0.05; 'implements': 0.07; 'key.': 0.07; 'python': 0.09; '"thanks': 0.09; 'substitution': 0.09; 'def': 0.10; '2.7': 0.13; 'alpha': 0.15; '"2":': 0.16; 'alphabet': 0.16; 'correctly,': 0.16; 'main():': 0.16; 'skip:" 70': 0.16; 'subject:String': 0.16; 'string': 0.17; '>>>': 0.18; 'code,': 0.18; 'input': 0.18; 'translate': 0.20; 'skip:" 30': 0.20; 'import': 0.21; '3.2': 0.22; 'help.': 0.22; 'header:In-Reply- To:1': 0.25; 'skip:" 20': 0.26; 'plain': 0.27; 'received:209.85.210.46': 0.27; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.27; 'coded': 0.29; 'letter.': 0.29; 'url:mailman': 0.29; 'probably': 0.29; "skip:' 10": 0.30; 'becomes': 0.30; 'basic': 0.30; 'stuff': 0.30; 'code': 0.31; '(and': 0.32; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'url:mail': 0.40; 'here': 0.65; 'secret': 0.71; 'spy': 0.84; 'cryptography': 0.91; 'subject:..': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Y6Vn3g3ug/XS43xhwForVUI6aQQ7L0i7INz5spb/Y9I=; b=H2Sv0x27nEweltGxOo15Nu1gDLZBsrZERJJs8Ta860cLY88AsREmja2XwB6YuiWKvr zv+U3lwwrxoaRJ2vnLrimdAR50WHrhCHgEpzUYbxQvVHPc7+Ol7H5EU3MRhSOfF5Kc2V Jmrm1Kzgu6sr5TZWmFTUsoHF0TZOZ3K5zqKDprNB7fYGv5+f0I+BYN1/mUkKruIXxASU gp7xI6BNm9l+QQNiCdJB/M19fsH5VDAaN+t3uLjYxQfSAGYJSg3I/6i9b1ZcyhqHIzYH l2Ckf+EWELcyhFKBa5VWiWk66WMZ8hSRfiqOVHKmxIRhBDqwUu8q6mpbD5WDqZZMHY/v vYiw== |
| MIME-Version | 1.0 |
| In-Reply-To | <d6779e35-32b8-417a-abf9-72454573bf56@googlegroups.com> |
| References | <d6779e35-32b8-417a-abf9-72454573bf56@googlegroups.com> |
| Date | Tue, 11 Dec 2012 00:25:58 +0100 |
| Subject | Re: String manipulation in python..NEED HELP!!!! |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.692.1355181961.29569.python-list@python.org> (permalink) |
| Lines | 64 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1355181961 news.xs4all.nl 6985 [2001:888:2000:d::a6]:60253 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:34580 |
Show key headers only | View raw
2012/12/10 <qbailey@ihets.org>:
> I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to mainpulate the string to do the encryption/decryption. please help
>
> here is my code so far:
>
>
> """ crypto.py
> Implements a simple substitution cypher
> """
>
> alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> key = "XPMGTDHLYONZBWEARKJUFSCIQV"
>
> def main():
> keepGoing = True
> while keepGoing:
> response = menu()
> if response == "1":
> plain = raw_input("text to be encoded: ")
> print encode(plain)
> elif response == "2":
> coded = raw_input("code to be decyphered: ")
> print decode(coded)
> elif response == "0":
> print "Thanks for doing secret spy stuff with me."
> keepGoing = False
> else:
> print "I don't know what you want to do..."
>
>
>
>
> i really need help on how to encrypt it im not sure how to go about doing that please help.
> --
> http://mail.python.org/mailman/listinfo/python-list
Hi,
if I understand correctly, for the data shown in the code, you may
probably use the translate method of the string (and the corresponding
maketrans method);
cf.:
python 2.7
>>> import string
>>> "ABCDEF...VWXYZ".translate(string.maketrans("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "XPMGTDHLYONZBWEARKJUFSCIQV"))
'XPMGTD...SCIQV'
>>>
python 3.2
>>> "ABCDEF...VWXYZ".translate("".maketrans("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "XPMGTDHLYONZBWEARKJUFSCIQV"))
'XPMGTD...SCIQV'
>>>
hth,
vbr
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String manipulation in python..NEED HELP!!!! qbailey@ihets.org - 2012-12-10 14:38 -0800
Re: String manipulation in python..NEED HELP!!!! John Gordon <gordon@panix.com> - 2012-12-10 22:59 +0000
Re: String manipulation in python..NEED HELP!!!! Terry Reedy <tjreedy@udel.edu> - 2012-12-11 14:30 -0500
Re: String manipulation in python..NEED HELP!!!! Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-12-11 15:52 -0500
Re: String manipulation in python..NEED HELP!!!! Tim Delaney <timothy.c.delaney@gmail.com> - 2012-12-12 08:34 +1100
Re: String manipulation in python..NEED HELP!!!! Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-12-11 00:25 +0100
Re: String manipulation in python..NEED HELP!!!! Chris Angelico <rosuav@gmail.com> - 2012-12-11 10:36 +1100
Re: String manipulation in python..NEED HELP!!!! duncan smith <buzzard@invalid.invalid> - 2012-12-11 16:39 +0000
Re: String manipulation in python..NEED HELP!!!! Peter Pearson <ppearson@nowhere.invalid> - 2012-12-11 22:21 +0000
csiph-web