
    g                     ,    d Z ddlZddlmZ ddlZddZy)zUtility functions.    N)OptionParserc                     t        dd      } | j                  ddddd	       | j                  d
dddd	       | j                  ddddd       | j                  ddddd       | j                  t        j                        \  }}|j
                  rft        d|j
                  d|j                  dt        j                         t        |j
                  d      5 }|j                         }ddd       nUt        d|j                  z  t        j                         t        j                  j                         j                  d      }t              t        k(  sJ t        |             t        j                   j"                  j%                  ||j                        }t        j                   j'                  |j(                  |j*                        }|j-                  |j.                        }|j0                  rgt        d|j0                  d|j.                  dt        j                         t        |j0                  d       5 }|j3                  |       ddd       yt        d!|j.                  z  t        j                         t        j4                  j3                  |j7                  d             y# 1 sw Y   yxY w# 1 sw Y   yxY w)"z=Reads a private key and outputs the corresponding public key.zusage: %prog [options]zReads a private key and outputs the corresponding public key. Both private and public keys use the format described in PKCS#1 v1.5)usagedescriptionz-iz--input
infilenamestringz1Input filename. Reads from stdin if not specified)desttypehelpz-oz--outputoutfilenamez2Output filename. Writes to stdout of not specifiedz--informinformz!key format of input - default PEM)PEMDERr   )r	   r   choicesdefaultz	--outformoutformz"key format of output - default PEMzReading private key from z in z format)filerbNz+Reading private key from stdin in %s formatasciizWriting public key to wbz)Writing public key to stdout in %s format)r   
add_option
parse_argssysargvr   printr   stderropenreadstdinencoder
   bytesrsakey
PrivateKey
load_pkcs1	PublicKeyne
save_pkcs1r   r   writestdoutdecode)	parserclicli_argsinfilein_datapriv_keypub_keyout_dataoutfiles	            =/var/www/openai/venv/lib/python3.12/site-packages/rsa/util.pyprivate_to_publicr7      sF    &.F @   A   0   1   ''1OS( ~~:=..#**U	
 #..$'6kkmG (' 	;cjjHszzZ)).."))'2=E!04=0! ww!!,,WcjjAHgg

HJJ7G !!#++.H
7:T	
 #//4(GMM(# )( 	9CKKGcjjY

121 ('( )(s    J>K>KK)returnN)__doc__r   optparser   rsa.keyr"   r7        r6   <module>r>      s     
 ! J3r=   