def setDateOfBirth(self, dateOfBirth): if self.Pubkey: self.DateOfBirth = rsa_encrypt(self.Pubkey, dateOfBirth.encode("utf-8)")) return 0 else: return 1
def test_rsa_encrypt(self): """ Verifies rsa_encrypt encrypts data properly """ data = b"When you're a kid, you don't realize you're also watching your mom and dad grow up." result = b'\x0f\x8d\xcd\x9by\xb6\xb8\xb7!\xe6\xff1\xc3\x0b\xfa\xba\xf1\xd0\xde\xcd\xac\xb9\xd1{\xef6\x07\xef\xa0\xa9\x18\xdc\xbf\x1fA\x1c5\xce\xc5LB(\xbf\x1f\x8ar\x0e\x88U\x9c\x9b\x1cg]\x8f\xbd\xd1\xae\xe4\x95.\r\xd0\xd2@\n\x11_<\xc4\x16\xfb8\x0ep\x06\x1cr:\nU\x0c\xc8L\xa0\x1d/\xa5\x11-1J\xc3\xdaQ \xcaam=\x05\x8a\xda\x80\x91\xf2\n\xcc\x83\xa7M\xbe6\x92:\x8d\n\t\xa6\xbf\xab/\xa18?\x93#\xa2' self.assertEqual(crypto.rsa_encrypt(self.rsa_keypair[1], data), result)
def setLastName(self, lastName): if self.Pubkey: self.LastName = rsa_encrypt(self.Pubkey, lastName.capitalize().encode("utf-8")) return 0 else: return 1
def setSymkey(self, Symkey=None): if self.Pubkey: if not Symkey: Symkey = gen_aes() self.Symkey = rsa_encrypt(self.Pubkey, Symkey) return 0 else: return 1
def setGender(self, gender): if self.Pubkey: self.Gender = rsa_encrypt(self.Pubkey, gender.encode("utf-8")) return 0 else: return 1
def setCreationDate(self, creation): self.CreationDate = rsa_encrypt(self.Pubkey, str(creation).encode('utf-8'))
def setAvailable(self, available): self.Available = rsa_encrypt(self.UserId.getPubkey(), available.encode("utf-8"))
def setPhonenumber(self, phoneNumber): self.Phonenumber = rsa_encrypt(self.UserId.getPubkey(), phoneNumber.encode("utf-8"))
def setName(self, name): self.Name = rsa_encrypt(self.UserId.getPubkey(), name.encode("utf-8"))