##### Can I do this faster?
 Can I do this faster? Gasimoe Unladen Swallow Posts: 1 Threads: 1 Joined: Feb 2017 Reputation: 0 Feb-28-2017, 06:22 PM (This post was last modified: Feb-28-2017, 06:23 PM by Gasimoe.) Hello! I´m making a RSA-encrypting/decrypting program. When I encrypt I use a list but t,e and n are big numbers so this take a while. Is there anyway python can do the exact same thing but faster? ```wordlist_krypterad = [(t ** e) % n for t in wordlist_ascii_int] ```Thanx! /Gasimoe Reply nilamo Last Thursdayist Posts: 3,290 Threads: 94 Joined: Sep 2016 Reputation: 138 Feb-28-2017, 06:37 PM I'd start by making it functional.  Once it works that way, you can look into paralleling it to take advantage of multiple cpu cores. Without actually testing the code, here's an example of making it functional: ```transform = lambda t: (t**e) % n wordlist_krypterad = map(transform, wordlist_ascii_int) ``` Reply stranac A Beautiful Pony Posts: 275 Threads: 6 Joined: Nov 2016 Reputation: 15 Feb-28-2017, 07:19 PM https://docs.python.org/3/library/functions.html#pow Reply zivoni Minister of Silly Walks Posts: 331 Threads: 2 Joined: Feb 2017 Reputation: 65 Feb-28-2017, 08:00 PM Another way could be using numpy (if your t and n fit into int32) - you are doing exactly same operation on list of numbers, if you transform it to 1-D array, you can manipulate them all at once. I am not sure if there is modular exponentiation in numpy - if not, to avoid overflow (and to speed it) you will need to implement it. With  binary exponentiation it could by quite fast. Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020