def makePublicKey(result): ''' Takes the result of the GetPublicKey amp call and converts it into a public key which the rsa module can handle. ''' return result return { 'e': pickle.decode_long(result['e']), 'n': pickle.decode_long(result['n']), }
async def load_long4(self): n, = unpack('<i', await self.read(4)) if n < 0: # Corrupt or hostile pickle -- we never write one like this raise UnpicklingError("LONG pickle has negative byte count") data = await self.read(n) self.append(decode_long(data))
def read_long4(f): n = read_int4(f) if n < 0: raise ValueError('long4 byte count < 0: %d' % n) data = f.read(n) if len(data) != n: raise ValueError('not enough data in stream to read long4') return decode_long(data)
def mklong(btwoc): """ Given a big-endian two's complement string, return the long int it represents. """ l = list(btwoc) l.reverse() result = pickle.decode_long(''.join(l)) log.msg('[mklong] given %r, made %r' % (btwoc, result)) return result
def binaryToLong(s): if not isinstance(s, unicode): s = unicode(s, encoding="utf-8") return pickle.decode_long(''.join(reversed(s)))
def binaryToLong(s): if isinstance(s, str): s = s.encode("utf-8") b = bytearray(s) b.reverse() return pickle.decode_long(bytes(b))
def binaryToLong(s): return pickle.decode_long(''.join(reversed(s)))
def load_long4(self): # Replace the internal implementation of pickle # cause `marshal.loads` has been blocked by the ODPS python sandbox. n = struct.unpack('<i', self.read(4))[0] bytes = self.read(n) self.append(pickle.decode_long(bytes))
import base64, pickle, urllib from google.appengine.ext import db from random import random segment = 1 class shared(db.Model): assocHandle = db.StringProperty() assocType = db.StringProperty() macKey = db.ByteStringProperty() btwocDec = lambda arg: pickle.decode_long(arg[::-1]) btwocEnc = lambda arg: pickle.encode_long(arg)[::-1] if arg else '\x00' base64Dec = lambda arg: btwocDec(base64.b64decode(arg.replace('-', '+').replace('_', '/'))) base64Enc = lambda arg: base64.b64encode(btwocEnc(arg)) def rndstr(length, alphabet): result = '' # Choose symbols from alphabet at random symbol = random() for _ in range(length): symbol *= len(alphabet) result += alphabet[int(symbol)] symbol -= int(symbol) return result class oneMany: def __init__(ctx, *args):
def dispatch_long4(self): # type: () -> None size = unpack('<i', self.f.read(4))[0] data = self.f.read(size) self.stack.append(pickle.decode_long(data))
def read_long1(f): n = read_uint1(f) data = f.read(n) if len(data) != n: raise ValueError('not enough data in stream to read long1') return decode_long(data)
def update_event(self, inp=-1): self.set_output_val(0, pickle.decode_long(self.input(0)))
async def load_long1(self): n = (await self.read(1))[0] data = await self.read(n) self.append(decode_long(data))
def unbtwoc(text): return pickle.decode_long(''.join(reversed(text)))
def _decodeVeryBigInt(read, n, typ, unpack=struct.unpack): if n == 1: return decode_long(read( unpack('I', read(4)) )) return [ decode_long(read( unpack('I', read(4))[0] )) for i in range(n) ]
def _decodeBigInt(read, n, typ): if n == 1: return decode_long(read( ord(read(1)) )) return [ decode_long(read( ord(read(1)) )) for i in range(n) ]
def _decodeBigInt(read, n, typ): if n == 1: return decode_long(read(ord(read(1)))) return [decode_long(read(ord(read(1)))) for i in range(n)]
def _load_long(self, node): data = self.file.load_array(node, str) return decode_long(data)
def _decodeVeryBigInt(read, n, typ, unpack=struct.unpack): if n == 1: return decode_long(read(unpack('I', read(4)))) return [decode_long(read(unpack('I', read(4))[0])) for i in range(n)]
def fromString(self, inString): return pickle.decode_long(inString)
def dispatch_long1(self): # type: () -> None size = ord(self.f.read(1)) data = self.f.read(size) self.stack.append(pickle.decode_long(data))