def dencrypt(M,bs,d,n): a=[] c="" i=0 end=len(M[0]) while i<end: if(i!=end-1): c=make(str(Pow.resMod(int(M[0][i]),d,n)),bs) else: c=make(str(Pow.resMod(int(M[0][i]),d,n)),M[1]) a.append(c) i+=1 return a
def encrypt(M,bs,e,n): f=make(str(M),3) i=0 batches=split(f,bs)[0] tail=split(f,bs)[1] while i<len(batches): batches[i]=str(Pow.resMod(int(batches[i]),e,n)) i+=1 return [batches, tail]
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Generate pseudo random numbers. Should not be used for security purposes.""" from '__go__/math/rand' import Uint32, Seed from '__go__/math' import Pow from '__go__/time' import Now BPF = 53 # Number of bits in a float RECIP_BPF = Pow(2, -BPF) # TODO: The random byte generator currently uses math.rand.Uint32 to generate # 4 bytes at a time. We should use math.rand.Read to generate the correct # number of bytes needed. This can be changed once there is a way to # allocate the needed []byte for Read from python and cast it to a list of # integers once it is filled. def _gorandom(nbytes): byte_arr = [] while len(byte_arr) < nbytes: i = Uint32() byte_arr.append(i & 0xff) byte_arr.append(i >> 8 & 0xff) byte_arr.append(i >> 16 & 0xff) byte_arr.append(i >> 24 & 0xff)
def pow(x, y): return Pow(float(x), float(y))
def main(): # LIS.run() # MAX_MAX.run() Pow.run(4, 8)
def findCoprime(K): n=findCoHelp(K,K,Pow.pow(10,100,10)) while(gcd(n,K)!=1 or n==0): n-=1 return n