• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyDes.triple_des函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyDes.triple_des函数的典型用法代码示例。如果您正苦于以下问题:Python triple_des函数的具体用法?Python triple_des怎么用?Python triple_des使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了triple_des函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: TesteCrypto

def TesteCrypto(Input, Tipo):
	#os.system("cls")
	StringOut = Input
	#Mensagem = str(raw_input('Informe uma mensagem: '))

	Senha    = '1234567894532112'

	if Tipo.upper() == 'E':
		try:
			StringOut = pyDes.triple_des(Senha).encrypt(Input, padmode=2)  
			StringOut = str(StringOut).replace("'","'+char(39)+'")

		except:
			pass
	elif Tipo.upper() == 'D':
		try:
			StringOut = pyDes.triple_des(Senha).decrypt(Input, padmode=2)
		except:
			pass
	else:
		return 'Nenhuma opcao valida informada!'

	

	#print 'Mensagem Cryptografada: "' + ciphertext +'"'
	#print 'Mensagem sem Cryptografia: "'+ plain_text + '"'

	return StringOut
开发者ID:marinellirubens,项目名称:Sonda,代码行数:28,代码来源:TesteEncrypt.py


示例2: fcn_3DES_CBC

def fcn_3DES_CBC(isCrypt, master, text):

    # process the master key
    _masterKey(master)

    # prepare the input text
    inputText = text
    if not isCrypt:
        # is decrypt and the input is hexa string
        inputText = "".join([ chr(int(text[i:i+2], 16)) for i in range(0, len(text), 2) ])

    # get the 3des key and iv
    mKey = _mkSeedDigest[0:24]
    mIV  = _mkSeedDigest[-8:]

    # create the triple-des object and decrypt
    cipher = pyDes.triple_des(mKey, pyDes.CBC, mIV, pad=None, padmode=pyDes.PAD_PKCS5)

    # crypt or decrypt
    value = cipher.encrypt(inputText) if isCrypt else cipher.decrypt(inputText)

    # make printable (if needed)
    if isCrypt:
        value = "".join( [ "%02.2x" % ord(i) for i in value ] )

    return value
开发者ID:MGDevelopment,项目名称:library,代码行数:26,代码来源:keygen.py


示例3: encrypt_pydes

    def encrypt_pydes(self, command):
        from pyDes import triple_des

        hashed_command = self.hash(command)
        des = triple_des(self.secret)
        result = des.encrypt(hashed_command)
        return result.encode('hex')
开发者ID:lejmr,项目名称:django-gopay,代码行数:7,代码来源:utils.py


示例4: main

def main():
    call('clear')
    print "Coldfusion DataSource Password Decryptor"
    print "Witten by James Luther"
    print " "
    parser = optparse.OptionParser(usage='%prog -p <hash>\n\nThis uses the' +\
                                    ' default seed value unleess one is spe' +\
                                    'cified with -s <"seed">\n', version='%' +\
                                    'prog Version 2.1\n')
    parser.add_option('-p','--hash',dest='hash',type='string',help='Coldfus' +\
                        'ion  Password Hash')
    parser.add_option('-s','--seed',dest='seed',type='string',help='Custom' +\
                        'seed value (must be in quotes)')
    (options, args) = parser.parse_args()

    pwd = options.hash
    seed = "[email protected][email protected][email protected]"
    key = pyDes.triple_des(seed)

    if (pwd == None):
        print parser.usage
        exit(0)
    if (options.seed != None):
        seed = options.seed
    decryptkey(key, pwd)
开发者ID:captainhooligan,项目名称:pythonTools,代码行数:25,代码来源:coldfusion_decrypt.py


示例5: DecryptBlock

def DecryptBlock(key, text):
    # Static salt
    salt = '\x83\x7D\xFC\x0F\x8E\xB3\xE8\x69\x73\xAF\xFF'

    # Master password notes:
    #
    # This *only* encrypts pasword fields, not username/etc.  fields.
    # According to http://nontroppo.org/test/Op7/FAQ/opera-users.html#wand-security
    # "if you do use a master password, the used password is a combination of the
    # master password and a 128-byte random portion created at the same time.
    # This random portion is stored outside wand.dat, also encrypted with the
    # master password."
    # Random portion mentioned seems to be opcert6.dat
    #
    # According to http://my.opera.com/community/forums/topic.dml?id=132880
    # "opcert6.dat contains all private keys you have created and the associated
    # client certificates you have requested and installed. The private keys are
    # protected by the security password. [...] A small block of data in the
    # opcert6.dat file is also used when you secure the wand and mail passwords
    # with the security password."

    h = hashlib.md5(salt + key).digest()
    h2 = hashlib.md5(h + salt + key).digest()

    key = h[:16] + h2[:8]
    iv = h2[-8:]

    if fastdes:
        return M2Crypto.EVP.Cipher(alg='des_ede3_cbc', key=key, iv=iv, op=0,
            padding=0).update(text)
    else:
        #print(pyDes.triple_des(key, pyDes.CBC, iv).decrypt(text))
        return pyDes.triple_des(key, pyDes.CBC, iv).decrypt(text)
开发者ID:atmouse-,项目名称:operapass-git,代码行数:33,代码来源:opwand.py


示例6: kcdecrypt

def kcdecrypt(key, iv, data):
    if len(data) == 0:
        #print>>stderr, "FileSize is 0"
        return data

    if len(data) % BLOCKSIZE != 0:
        return data

    cipher = triple_des(key, CBC, iv)
    # the line below is for pycrypto instead
    #cipher = DES3.new( key, DES3.MODE_CBC, iv )

    plain = cipher.decrypt(data)

    # now check padding
    pad = ord(plain[-1])
    if pad > 8:
        #print>> stderr, "Bad padding byte. You probably have a wrong password"
        return ''

    for z in plain[-pad:]:
        if ord(z) != pad:
            #print>> stderr, "Bad padding. You probably have a wrong password"
            return ''

    plain = plain[:-pad]

    return plain
开发者ID:LucaBongiorni,项目名称:chainbreaker,代码行数:28,代码来源:chainbreaker.py


示例7: tpv_sig_data

def tpv_sig_data(mdata, order, key, alt=b"+/"):
    k = b64decode(key.encode(), alt)
    x = triple_des(k, CBC, b"\0\0\0\0\0\0\0\0", pad="\0")
    okey = x.encrypt(order.encode())
    sig = hmac.new(okey, mdata.encode(), sha256).digest()
    sigb = b64encode(sig, alt).decode()
    return sigb
开发者ID:wadobo,项目名称:congressus,代码行数:7,代码来源:views.py


示例8: UserEncryption

def UserEncryption(username,password):
    key=GetKeyID()[0:24]
    content=str(username)+'&*&'+password
    k = pyDes.triple_des(key,pyDes.CBC, lv, pad=None,padmode=pyDes.PAD_PKCS5)
    d = k.encrypt(content)
    s = binascii.hexlify(d)
    return base64.b64encode(s)
开发者ID:scp10011,项目名称:BITC_TaskUp,代码行数:7,代码来源:UserSave.py


示例9: make_tripleDES

def make_tripleDES():
    return pyDes.triple_des(
        derive_md5_key(settings.SECRET_KEY),
        pyDes.CBC,
        IV="\0\0\0\0\0\0\0\0",
        padmode=pyDes.PAD_PKCS5
    )
开发者ID:magenta-aps,项目名称:aalborg-monitor,代码行数:7,代码来源:utils.py


示例10: encrypt

 def encrypt(self, data):
     iv = binascii.unhexlify(self.iv)
     key = binascii.unhexlify(self.key)
     k = pyDes.triple_des(key, pyDes.CBC, iv, pad=None, padmode=pyDes.PAD_PKCS5)
     d = k.encrypt(data)
     d = base64.encodestring(d)
     return d
开发者ID:yfjelley,项目名称:des,代码行数:7,代码来源:pydestest.py


示例11: decrypt

def decrypt (data):
	
	# hex2bin
	ct = a2b_hex (data)
	
	# Extract the encrypted password
	enc = ct[40:]
	
	# Extract the IV
	iv = ct[:8]
	
	# Construct the key
	ht = ct[:19] + chr(ord(ct[19])+1)
	key = hashlib.sha1(ht).digest()
	
	ht = ht[:19] + chr(ord(ht[19])+2)
	key += hashlib.sha1(ht).digest()[:4]
	
	# Decrypt the password
	des = pyDes.triple_des (key, pyDes.CBC, iv)#, padmode = pyDes.PAD_PKCS5)
	pwd = des.decrypt (enc)
	
	print ord(pwd[-1])
	
	return pwd #[:-1]
开发者ID:JulGor,项目名称:Cryptography,代码行数:25,代码来源:ciscovpnclient.py


示例12: kcdecrypt

def kcdecrypt( key, iv, data ):

	if len(data) % BLOCKSIZE != 0:
		raise "Bad decryption data len isn't a blocksize multiple"

	cipher = triple_des( key, CBC, iv )
	# the line below is for pycrypto instead
	#cipher = DES3.new( key, DES3.MODE_CBC, iv )

	plain = cipher.decrypt( data )

	# now check padding
	pad = ord(plain[-1])
	if pad > 8:
		print>>stderr, "Bad padding byte. You probably have a wrong password"
		exit(1)

	for z in plain[-pad:]:
		if ord(z) != pad:
			print>>stderr, "Bad padding. You probably have a wrong password"
			exit(1)

	plain = plain[:-pad]

	return plain
开发者ID:DarthNihilus,项目名称:pushproxy,代码行数:25,代码来源:extractkeychain.py


示例13: encrypt_pydes

 def encrypt_pydes(self, command):
     hashed_command = self.hash(command)
     des = triple_des(self.secret)
     result = des.encrypt(hashed_command)
     if sys.version_info[0] < 3:
         return result.encode('hex')
     else:
         return result.hex()
开发者ID:farin,项目名称:gopay4django,代码行数:8,代码来源:crypt.py


示例14: __init__

    def __init__(self, key):
        if len(key) < 24:
            key = key + b64encode(key.encode("utf-8"))
            key = key + b64encode(key.encode("utf-8")) * 2

        key = key[0:24]

        self.k = pyDes.triple_des(key.encode("utf-8"), CBC, "12345678", pad=None, padmode=PAD_PKCS5)
开发者ID:nilecui,项目名称:nile_python_swk,代码行数:8,代码来源:me_http.py


示例15: __init__

 def __init__(self,acc,pwd,mac,server,key):
     self._acc=acc
     self._pwd=pwd
     self._mac=mac
     self._server=server
     self._key=key
     self._aes=pyAes.new(key,1)
     self._des=pyDes.triple_des('1234ZHEJIANGXINLIWANGLEI',pyDes.CBC,'12345678')
开发者ID:Sg4Dylan,项目名称:MoMo-HeartBeat,代码行数:8,代码来源:MoMo-HeartBeat.py


示例16: decode

def decode(data):
    if not data:
        return ''
    k = pyDes.triple_des((str(uuid.getnode()) * 2)[0:24],
                         pyDes.CBC,
                         "\0\0\0\0\0\0\0\0",
                         padmode=pyDes.PAD_PKCS5)
    return k.decrypt(base64.b64decode(data))
开发者ID:phil65,项目名称:plugin.video.amazon65,代码行数:8,代码来源:common.py


示例17: decrypt

 def decrypt(data, pinid):
     key = get_wxlt_config(pinid).get('des_key')
     if len(key) < 24: key += ' ' * (24 - len(key))
     if len(key) > 24: key = key[:24]
     vi = '12345678'
     data = b64decode(data)
     k = triple_des(key, CBC, vi, pad=None, padmode=PAD_PKCS5)
     d = k.decrypt(data)
     return d
开发者ID:wjchao9111,项目名称:X,代码行数:9,代码来源:wxlt_service.py


示例18: decode_private_key

def decode_private_key():

	# Before anything else, let's get the four passwords.
	print
	print "We need four passwords to decrypt your private key"
	print "Enter the words, one at a time, when prompted."
	print
	global options
	if options.pass1:
		p1 = options.pass1
	else:
		p1 = getpass.getpass("Password One: ")
	if options.pass2:
		p2 = options.pass2
	else: 
		p2 = getpass.getpass("Password Two: ")
	if options.pass3:
		p3 = options.pass3
	else:
		p3 = getpass.getpass("Password Three: ")
	if options.pass4:
		p4 = options.pass4
	else:
		p4 = getpass.getpass("Password Four: ")
	whole_pass = p3+p1+p2+p4   # Concatenate the passwords

	#
	# Create a 48-bit has based on the string of the passwords
	# Then, based on the value of bit 7 of the last byte,
	# Use either the upper or low half of the hash value
	# Because TripleDES requires a 24-bit seed key thingy.
	#
	scram = hashlib.sha384(whole_pass).digest()
	hi_lo = ord(scram[47]) & 0x80  # Use the hash to figure out which half to use
	if hi_lo:
		scram_half = scram[:24]
	else:
		scram_half = scram[24:]

	# Create a TripleDES encryptor for the key 
	k = pyDes.triple_des(scram_half, pyDes.CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5)  # Create encryptor

	privkey_fn = os.path.join(os.path.expanduser('~'),'.cryptweet-privkey-sec') # Path to secure private keyfile
	privkey_encrypted_file = open(privkey_fn, "r")
	privkey_encrypted = privkey_encrypted_file.read()
	privkey_encrypted_file.close()	

	# Decrypt the file, if we can, then convert it to an object
	try:
		privkey_pem = k.decrypt(privkey_encrypted)
		privkey = rsa.PrivateKey.load_pkcs1(privkey_pem, format='PEM') # @sylmobile bug reported 12 Feb
	except:
		print "Encryption failure -- bad passwords?"
		return None

	return privkey
开发者ID:mpesce,项目名称:CrypTweet,代码行数:56,代码来源:ctrx.py


示例19: decrypt

 def decrypt(self, data):
     iv = binascii.unhexlify(self.iv)
     key = binascii.unhexlify(self.key)
     k = pyDes.triple_des(key, pyDes.CBC, iv, pad=None, padmode=pyDes.PAD_PKCS5)
     try:
         data = base64.decodestring(data)
         d = k.decrypt(data)
     except:
         d = ''
     return d
开发者ID:yfjelley,项目名称:des,代码行数:10,代码来源:pydestest.py


示例20: sk_decode

def sk_decode(request,password):
    iv =  md5(password.encode('utf-8')).hexdigest()
    if len(iv) >=24:
        iv = iv[0:24]
    else:
        iv = iv+"0"*(24-len(iv))
                    
    k = triple_des(iv,padmode=PAD_PKCS5)
    result = k.decrypt(base64.b64decode(request)).decode("utf8")
    return result;
开发者ID:lycying,项目名称:seeking,代码行数:10,代码来源:security.py



注:本文中的pyDes.triple_des函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyEQL.unit函数代码示例发布时间:2022-05-25
下一篇:
Python pyDes.des函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap