

'''simple docstring'''







import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

__lowerCamelCase									=     3
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      int:
       print("""Generating primitive root of p"""					)
       while True:
              A_						       =   random.randrange(3,							UpperCAmelCase__					)
              if pow(UpperCAmelCase__,							2,							UpperCAmelCase__					) == 1:
                     continue
              if pow(UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__					) == 1:
                     continue
              return g
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      tuple[tuple[int, int, int, int], tuple[int, int]]:
       print("""Generating prime p..."""					)
       A_						       =   rabin_miller.generate_large_prime(UpperCAmelCase__					)  # select large prime number.
       A_						       =   primitive_root(UpperCAmelCase__					)  # one primitive root on modulo p.
       A_						       =   random.randrange(3,							UpperCAmelCase__					)  # private_key -> have to be greater than 2 for safety.
       A_						       =   cryptomath.find_mod_inverse(pow(UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__					),							UpperCAmelCase__					)

       A_						       =   (key_size, e_a, e_a, p)
       A_						       =   (key_size, d)

       return public_key, private_key
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      None:
       if os.path.exists(F'''{name}_pubkey.txt'''					) or os.path.exists(F'''{name}_privkey.txt'''					):
              print("""\nWARNING:"""					)
              print(
                  F'''"{name}_pubkey.txt" or "{name}_privkey.txt" already exists. \n'''
                  """Use a different name or delete these files and re-run this program."""					)
              sys.exit()

       A_       ,      A_						       =   generate_key(UpperCAmelCase__					)
       print(F'''\nWriting public key to file {name}_pubkey.txt...'''					)
       with open(F'''{name}_pubkey.txt''',							"""w"""					) as fo:
              fo.write(F'''{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}'''					)

       print(F'''Writing private key to file {name}_privkey.txt...'''					)
       with open(F'''{name}_privkey.txt''',							"""w"""					) as fo:
              fo.write(F'''{private_key[0]},{private_key[1]}'''					)
def    UpperCAmelCase__     (   )      ->      None:
       print("""Making key files..."""					)
       make_key_files("""elgamal""",							20_48					)
       print("""Key files generation successful"""					)


if __name__ == "__main__":
      main()



'''simple docstring'''







import csv

import tweepy

# Twitter API credentials
__lowerCamelCase									=     ''''''
__lowerCamelCase									=     ''''''
__lowerCamelCase									=     ''''''
__lowerCamelCase									=     ''''''
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      None:
       # authorize twitter, initialize tweepy
       A_						       =   tweepy.OAuthHandler(UpperCAmelCase__,							UpperCAmelCase__					)
       auth.set_access_token(UpperCAmelCase__,							UpperCAmelCase__					)
       A_						       =   tweepy.API(UpperCAmelCase__					)

       # initialize a list to hold all the tweepy Tweets
       A_						       =   []

       # make initial request for most recent tweets (200 is the maximum allowed count)
       A_						       =   api.user_timeline(screen_name=UpperCAmelCase__,							count=2_00					)

       # save most recent tweets
       alltweets.extend(UpperCAmelCase__					)

       # save the id of the oldest tweet less one
       A_						       =   alltweets[-1].id - 1

       # keep grabbing tweets until there are no tweets left to grab
       while len(UpperCAmelCase__					) > 0:
              print(F'''getting tweets before {oldest}'''					)

              # all subsequent requests use the max_id param to prevent duplicates
              A_						       =   api.user_timeline(
                  screen_name=UpperCAmelCase__,							count=2_00,							max_id=UpperCAmelCase__					)

              # save most recent tweets
              alltweets.extend(UpperCAmelCase__					)

              # update the id of the oldest tweet less one
              A_						       =   alltweets[-1].id - 1

              print(F'''...{len(UpperCAmelCase__					)} tweets downloaded so far'''					)

       # transform the tweepy tweets into a 2D array that will populate the csv
       A_						       =   [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

       # write the csv
       with open(F'''new_{screen_name}_tweets.csv''',							"""w"""					) as f:
              A_						       =   csv.writer(UpperCAmelCase__					)
              writer.writerow(["""id""", """created_at""", """text"""]					)
              writer.writerows(UpperCAmelCase__					)


if __name__ == "__main__":
      # pass in the username of the account you want to download
      get_all_tweets('''FirePing32''')
