



"""simple docstring"""





import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812
def      a__			(   ):
      print("Making key files..."   )
      make_key_files("rsa"			,    1024   )
      print("Key files generation successful."   )
def      a__			(   lowerCAmelCase__   ):
      print("Generating prime p..."   )
      UpperCAmelCase_    				=							rabinMiller.generate_large_prime(lowerCAmelCase__   )
      print("Generating prime q..."   )
      UpperCAmelCase_    				=							rabinMiller.generate_large_prime(lowerCAmelCase__   )
      UpperCAmelCase_    				=							p * q

      print("Generating e that is relatively prime to (p - 1) * (q - 1)..."   )
      while True:
            UpperCAmelCase_    				=							random.randrange(2 ** (key_size - 1)			,    2 ** (key_size)   )
            if cryptoMath.gcd(lowerCAmelCase__			,    (p - 1) * (q - 1)   ) == 1:
                  break

      print("Calculating d that is mod inverse of e..."   )
      UpperCAmelCase_    				=							cryptoMath.find_mod_inverse(lowerCAmelCase__			,    (p - 1) * (q - 1)   )

      UpperCAmelCase_    				=							(n, e)
      UpperCAmelCase_    				=							(n, d)
      return (public_key, private_key)
def      a__			(   lowerCAmelCase__			,    lowerCAmelCase__   ):
      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()

      UpperCAmelCase_				,					UpperCAmelCase_    				=							generate_key(lowerCAmelCase__   )
      print(f"""\nWriting public key to file {name}_pubkey.txt..."""   )
      with open(f"""{name}_pubkey.txt"""			,    "w"   ) as out_file:
            out_file.write(f"""{key_size},{public_key[0]},{public_key[1]}"""   )

      print(f"""Writing private key to file {name}_privkey.txt..."""   )
      with open(f"""{name}_privkey.txt"""			,    "w"   ) as out_file:
            out_file.write(f"""{key_size},{private_key[0]},{private_key[1]}"""   )


if __name__ == "__main__":
 main()









"""simple docstring"""





from __future__ import annotations
def      a__			(   lowerCAmelCase__   ):
      if len(lowerCAmelCase__   ) == 0:
            return []
      UpperCAmelCase_				,					UpperCAmelCase_    				=							min(lowerCAmelCase__   ), max(lowerCAmelCase__   )
      UpperCAmelCase_    				=							int(max_value - min_value   ) + 1
      UpperCAmelCase_    				=							[[] for _ in range(lowerCAmelCase__   )]

      for i in my_list:
            buckets[int(i - min_value   )].append(lowerCAmelCase__   )

      return [v for bucket in buckets for v in sorted(lowerCAmelCase__   )]


if __name__ == "__main__":
  from doctest import testmod

  testmod()
  assert bucket_sort([4, 5, 3, 2, 1]) == [1, 2, 3, 4, 5]
  assert bucket_sort([0, 1, -10, 15, 2, -2]) == [-10, -2, 0, 1, 2, 15]




