3

Èîdd¹"ã@sRdd„Zdd„Zdd„Zdd„Zddd	„Zd
d„Zdd
„Zddd„Zddd„ZdS)cCs(ddl}t|dƒ}|j|ƒ}|jƒ}|S)Nézutf-8)Úbase64Ú	bytearrayÚ	b64encodeÚdecode)ÚstringrÚ
byte_arrayÚencrypted_bytesÚencrypted_string©r
ú3/home/s/sultans/web/python/demo/etl/util/encrypt.pyÚencrypts


rcCs(ddl}t|dƒ}|j|ƒ}|jƒ}|S)Nrzutf-8)rrÚ	b64decoder)r	rrrrr
r
rÚdecrypts


rcCsBddl}ddlm}t|dƒ}|j|ƒ}||ƒ}|j|jƒƒ}|S)Nr)ÚFernetzutf-8)rÚcryptography.fernetrÚbytesÚurlsafe_b64encoderÚencode)ÚstrÚpswdrrÚkeyÚfernetZ
encrypted_strr
r
rÚencrypt2(s

rcCsBddl}ddlm}t|dƒ}|j|ƒ}||ƒ}|j|ƒjƒ}|S)Nr)rzutf-8)rrrrrrr)rrrrrrZ
decrypted_strr
r
rÚdecrypt28s

rcCs¶d}d}d}d}||||}d}x|D]}	|t|	ƒ7}q*W|t|ƒ}
|
dkrVd}
|jƒdkr€|}||
d…|d|
…}n||
d…|d|
…}|}|j||ƒ}
|j|
ƒ}|S)NZABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyzÚ
0123456789z~!@#$%^&*:;.',?+=/rér)ÚordÚlenÚlowerÚ	maketransÚ	translate)rrÚ	directionZ	uppercaseZ	lowercaseÚnumbersZpunctuationÚbaseÚseedÚcharÚoffsetÚsourceÚtargetZ
transTableZ	newStringr
r
rÚcryptGs&

r)cCst||dƒS)Nr)r))rrr
r
rÚencrypt3fsr*cCst||dƒS)Nr)r))rrr
r
rÚdecrypt3osr+ÚmysqlcCsL|dkrd}nd}t|dƒ}t||ƒ}|d|d}|j|ƒ|jƒ|S)Nr,z5/home/sultans/web/python/demo/etl/util/mysql_keys.txtz6/home/sultans/web/python/demo/etl/util/oracle_keys.txtÚaú=Ú
)Úopenr*ÚwriteÚclose)ÚnameÚconnection_stringÚdbÚfileÚoutputr	Znew_connectionr
r
rÚadd_connection_stringxs


r8c
Csr|dkrd}nd}t|dƒ}|jƒ}|jƒ|jdƒ}x2|D]*}|jddƒ\}}||kr<t||ƒ}	|	Sq<W|dS)	Nr,z5/home/sultans/web/python/demo/etl/util/mysql_keys.txtz6/home/sultans/web/python/demo/etl/util/oracle_keys.txtÚrr/r.rz
 Not found)r0Úreadr2Úsplitr+)
r3r5r6ÚinputÚlinesZconnection_stringsÚlineÚ
connectionr	r4r
r
rÚget_connection_string‹s



r@N)r)r,)r,)	rrrrr)r*r+r8r@r
r
r
rÚ<module>s