def AddSite(self, name, url=u'', port=u'21', user=u'', pword=u'', path=u'', enc=u'utf-8'): """Add/Update a site in the configuration @param name: configuration name @keyword url: site url @keyword port: port number @keyword user: username @keyword pword: password @keyword path: default path @keyword enc: encoding """ data = dict(url=url, port=port, user=user, pword=pword, path=path, enc=enc) salt = os.urandom(8) pword = ed_crypt.Encrypt(data['pword'], salt) data['salt'] = salt data['pword'] = pword self._data[name] = data # Notify all others of change ed_msg.PostMessage(EDMSG_FTPCFG_UPDATED, (name, ))
def testDecrypt(self): """Test decrypting a string""" e_str = ed_crypt.Encrypt(self.secret, self.salt) self.assertTrue(e_str != self.secret) self.assertTrue(len(e_str) > 0) d_str = ed_crypt.Decrypt(e_str, self.salt) self.assertTrue(d_str == self.secret)