roibin 发表于 2013-2-5 02:18:04

加密器

加密器

在/usr/local下创建encrypt.py
设置key1和key2,两个随机数。
sudo chmod 4755 encrypt.py
sudo ln -s encrypt.py encrypt

usage:encrypt 123456

#!/usr/bin/python#filename=encrypt.pyimport gtkimport sysclass encode():key1 = intKey1key2 = intKey2def ascii_list(self, s):    """return a list of ascii values of the characters in string s"""    return def byte_list(self, c):    """return a list of bytes values of the"""    return def encrypt(self, strContent_param):    listBytes = self.ascii_list(strContent_param)    i = 0    for byte in listBytes:      if ((byte > 47) and (byte < 58)):      listBytes = byte - 48      elif ((byte > 64) and (byte < 91)):      listBytes = byte - 55      elif ((byte > 96) and (byte < 123)):      listBytes = byte - 61      else:      break      listBytes = (self.key1 + i * self.key2) % 62 + listBytes      if (listBytes > 61):      listBytes = listBytes - 62      if ((listBytes >= 0) and (listBytes < 10)):      listBytes = listBytes + 48      elif ((listBytes > 9) and (listBytes < 36)):      listBytes = listBytes + 55      elif ((listBytes > 35) and (listBytes < 62)):      listBytes = listBytes + 61      else:      break      i = i + 1    listChar = self.byte_list(listBytes)    return ''.join(listChar)def main(args):en = encode()encryption = en.encrypt(args)print encryptioncb = gtk.clipboard_get()cb.set_text(encryption)cb.store()if __name__ == "__main__":main(sys.argv)

如此复制到clipboard的方式,对于terminal下使用shift+insert组合键无效,只能使用鼠标右键再点击“粘贴”。
页: [1]
查看完整版本: 加密器