|
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
from cStringIO import StringIO
from PIL import Image
import urllib, base64
# 이미지 객체에서 값 얻기
base = Image.new('RGBA', (w, h), (0, 0, 0, 0))
# do something on Image object
raw = StringIO()
base.save(raw, 'PNG')
b64png = 'https://t1.daumcdn.net/cfile/tistory/2362D34056EA60EB26"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">
file = urllib2.urlopen(url)
buf = StringIO(file.read())
b64png = 'https://t1.daumcdn.net/cfile/tistory/2623EE4156EA60EC25Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |
Python에서 base64 이미지 데이터 만들기 (0) | 2012.02.04 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |
Python에서 base64 이미지 데이터 만들기 (0) | 2012.02.04 |
---|---|
Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |
Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |
Python과 M2Crypto를 이용한 RSA 암/복호화 (1) | 2011.05.30 |
Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |
Python과 M2Crypto를 이용한 RSA 암/복호화 (1) | 2011.05.30 |
import os
import cStringIO
from M2Crypto import EVP
skey = os.urandom(16)
plaintext = '12345'
# encrypt
aes = EVP.Cipher(alg='aes_128_ecb', key=skey, iv='', op=1)
buf = cStringIO.StringIO()
buf.write(aes.update(plaintext))
buf.write(aes.final())
ciphertext = buf.getvalue()
# decrypt
aes = EVP.Cipher(alg='aes_128_ecb', key=skey, iv='', op=0)
buf = cStringIO.StringIO()
buf.write(aes.update(ciphertext))
buf.write(aes.final())
plaintext = buf.getvalue()Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 RSA 암/복호화 (1) | 2011.05.30 |
import base64
import binascii
from M2Crypto import BIO, RSA
plain_text = '12345'
TEMPLATE = """-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----"""
raw = binascii.a2b_hex(pub_key_hex)
data = TEMPLATE % base64.encodestring(raw).rstrip()
bio = BIO.MemoryBuffer(data)
pub_key = RSA.load_pub_key_bio(bio)
enc = pub_key.public_encrypt(plain_text, RSA.pkcs1_oaep_padding)
enc_text = binascii.b2a_hex(enc_text)
TEMPLATE = """-----BEGIN RSA PRIVATE KEY-----\n%s\n-----END RSA PRIVATE KEY-----"""
raw = binascii.b2a_hex(priv_key_hex)
data = TEMPLATE % base64.encodestring(raw).rstrip()
priv_key = RSA.load_key_string(data)
enc = binascii.a2b_hex(enc_text)
plain_text = priv_key.private_decrypt(enc, M2Crypto.RSA.pkcs1_oaep_padding)
Mac OS X - Lion으로 업데이트 후 Python 환경 초기화 문제 (0) | 2011.10.27 |
---|---|
MySQL 5.5에서 MySQL-python 1.2.3 설치하기 (0) | 2011.06.09 |
Python Extension Package들에 대한 비공식 윈도우 바이너리들 (0) | 2011.06.09 |
Python에서 random 값을 얻기 위한 여러가지 방법들 (0) | 2011.06.09 |
Python과 M2Crypto를 이용한 AES 암/복호화 (581159) | 2011.06.02 |