MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/572196_RSA/recipe-572196.py:184–195  ·  view source on GitHub ↗
(self,fileobj,password,bits=128,mode="rb")

Source from the content-addressed store, hash-verified

182 # later read. It takes a string as a password that it uses to generate
183 # both prime numbers and the encryption key.
184 def __init__(self,fileobj,password,bits=128,mode="rb"):
185 # Function must be passed an open file or a file name,
186 # and on operating systems where this matters, the
187 # binary attribute must be set.
188 # For example, open("file","rb"), not open("file","r")
189 if type(fileobj)==str:
190 fileobj=open(fileobj,mode)
191 self.f=fileobj
192 self.e,self.d,self.n=passwordToKey(password,bits//2)
193 self.bits=bits
194 self.rbuf=""
195 self.wbuf=""
196 def write(self,data):
197 self.wbuf+=data
198 e,n,bits,bytes=self.e,self.n,self.bits,self.bits//8

Callers

nothing calls this directly

Calls 2

passwordToKeyFunction · 0.85
openFunction · 0.50

Tested by

no test coverage detected