본문 바로가기

Python4

[Python] 프록시 서버 - http,https 통신 예제 # -*- coding: utf-8 -*- import sys import os import socket import ssl import select import httplib import urlparse import threading import gzip import zlib import time import json import re from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn from cStringIO import StringIO from subprocess import Popen, PIPE from HTMLParser import HTMLParser def wi.. 2018. 7. 26.
[Python] 멀티 프로세스,멀티 쓰레드 예제코드 import struct import time import threading import pycurl import re import os from StringIO import StringIO from multiprocessing import Process,current_process,Pool,freeze_support up= lambda x:struct.unpack("L",x) #Little Endian class KMS(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print "Call Thread" def mp(number): #proc_name = current_process().name re.. 2018. 7. 16.
[Python] DES 예제 import requests, urllib, json import base64 import pyDes class DES: def __init__(self, iv, key): self.iv = iv self.key = key def encrypt(self, data): k = pyDes.des(self.key, pyDes.ECB, self.iv, pad=None, padmode=pyDes.PAD_PKCS5) d = k.encrypt(data) d = base64.encodestring(d) return d def decrypt(self, data): k = pyDes.des(self.key, pyDes.ECB, self.iv, pad=None, padmode=pyDes.PAD_PKCS5) d = k.dec.. 2018. 2. 6.
[Python] AES 예제 import base64 from Crypto.Cipher import AES from Crypto import Random pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) unpad = lambda s : s[:-ord(s[len(s)-1:])] class AESCipher: def __init__( self, key ): self.key = key def encrypt( self, raw ): raw = pad(raw) iv = Random.new().read( AES.block_size ) cipher = AES.new( self.key, AES.MODE_CBC, iv ) return base64.b64encode( iv + ciphe.. 2018. 2. 6.
반응형