예제 #1
0
# -*- coding: utf-8 -*-
"""@package utils.auth_utils
	access_token 加密解密工具
"""
import urllib
from util import msg_crypt
import settings

crypt = msg_crypt.MsgCrypt(settings.CTYPT_INFO['token'],
                           settings.CTYPT_INFO['encodingAESKey'],
                           settings.CTYPT_INFO['id'])


def encrypt_access_token(woid, openid='notopenid'):
    """
	使用msg_crypt加密包对由woid和openid组成的woid_weizoom_openid(eg:12_weizoom_xxxxxxxxxxx)字符串进行加密
	
	@param woid
	@param openid
	"""
    if not woid:
        raise ValueError('error woid')
    access_token_str = str(woid) + '_weizoom_' + openid
    encrypt_msg = crypt.EncryptMsg(access_token_str)
    encrypt_msg = urllib.quote(encrypt_msg)
    return encrypt_msg


def decrypt_access_token(msg):
    """
	使用msg_crypt加解密包对msg解密
예제 #2
0
from eaglet.utils.resource_client import Resource
from eaglet.decorator import param_required
from db.member import models as member_models

from business import model as business_model
from business.tengyi_member.tengyi_rebate_details import TengyiRebateDetails
from db.mall import models as mall_models
import settings

from eaglet.core import watchdog
from util import msg_crypt

# r = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_COMMON_DB)

crypt = msg_crypt.MsgCrypt(settings.WZCARD_ENCRYPT_INFO['token'],
                           settings.WZCARD_ENCRYPT_INFO['encodingAESKey'],
                           settings.WZCARD_ENCRYPT_INFO['id'])
CAN_USE_TEXT = u'可用'  #card_apiserver中定义的微众卡可用状态的文本


class MemberCard(business_model.Model):
    """
	会员卡
	"""
    __slots__ = (
        'id',
        'member_id',
        'batch_id',
        'card_number',
        'card_password',
        'card_name',