des

python实现DES及简单图像化界面

六眼飞鱼酱① 提交于 2020-01-03 08:42:33
DES算法简单介绍 DES是一种分组密码。明文、密文和密钥的分组长度都是64位; DES是面向二进制的密码算法,因而能够加解密任何形式的计算机数据; DES是对合运算,因而加解密共用同一个算法,从而使工程实现的工作量减半; DES的密码结构属于Feistel结构,这种结构是IBM的密码专家Feistel最早提出的。 DES算法的细节网上有很多,因此不详细展开。 代码结构主要包括: 子密钥的产生:置换选择1,循环左移,置换选择2; 初始置换IP; 加密函数f:选择运算E,代替函数组S(也就是S盒处理),置换运算; 逆初始置换IP; DES最后加解密。 没有规范学习过python,代码风格可能不太好,直接硬写,对于代码风格以及实现过程若有错误或者建议,恳请指出。 tkinter效果 实现代码 DES.py # -*- coding: utf-8 -*- # DES.py #生成子密钥 #64位密钥经过置换选择1、循环左移、置换选择2等变换,产生16个48位长的子密钥 #参数是64位密钥 def generkey ( key ) : keylist = list ( key ) #将输入密钥转换为列表 #置换选择1 left = [ 57 , 49 , 41 , 33 , 25 , 17 , 9 , 1 , 58 , 50 , 42 , 34 , 26 , 18 , 10 , 2 ,

Brute forcing DES with a weak key

▼魔方 西西 提交于 2020-01-01 04:27:06
问题 I am taking a course on Cryptography and am stuck on an assignment. The instructions are as follows: The plaintext plain6.txt has been encrypted with DES to encrypt6.dat using a 64-bit key given as a string of 8 characters (64 bits of which every 8th bit is ignored), all characters being letters (lower-case or upper-case) and digits (0 to 9). To complete the assignment, send me the encryption key before February 12, 23.59. Note: I expect to get an 8-byte (64-bits) key. Each byte should

python: how to encrypt a file?

百般思念 提交于 2019-12-31 02:32:06
问题 Can anybody help(or point to some examples) about how to encrypt files with python? I have to use following parameters to encrypt file: block size=8 iv=qwertyui12345678 method=des3_cbc Also I have no idea about what iv means Please help. Thanks in advance. 回答1: You will need to use the Python Crypto Toolkit IV is the Initialisation Vector. 回答2: Use pycrypto - note that implmenting crypto properly, even using a library for the hard parts, is tricky. If security matters get expert help. 回答3: IV

python递归:汉诺塔问题最简洁的算法

[亡魂溺海] 提交于 2019-12-26 09:51:40
使用python的递归做一个简洁的解法: def hanoi ( src , des , mid , n ) : global steps if n == 1 : steps += 1 print ( "[STEP{:>4}] {}->{}" . format ( steps , src , des ) ) else : hanoi ( src , mid , des , n - 1 ) steps += 1 print ( "[STEP{:>4}] {}->{}" . format ( steps , src , des ) ) hanoi ( mid , des , src , n - 1 ) if __name__ == "__main__" : steps = 0 N = eval ( input ( ) ) hanoi ( "A" , "C" , "B" , N ) 效果如图: 来源: CSDN 作者: Memory逆光 链接: https://blog.csdn.net/weixin_44936889/article/details/103706728

Using Triple DES(3DES) with PHP 7.1 [closed]

纵饮孤独 提交于 2019-12-25 12:57:27
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 10 months ago . I need a way to encrypt and decrypt with 3des. I'm currently using php 7.1 I found this question, but mcrypt is deprecated as of php 7.1 and I can't find any other resource for this. 回答1: Continue to the Comments section of the function's manual and you'll see the following: If

Using Triple DES(3DES) with PHP 7.1 [closed]

空扰寡人 提交于 2019-12-25 12:57:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 10 months ago . I need a way to encrypt and decrypt with 3des. I'm currently using php 7.1 I found this question, but mcrypt is deprecated as of php 7.1 and I can't find any other resource for this. 回答1: Continue to the Comments section of the function's manual and you'll see the following: If

How to extract the IV vector generated by encrypt method from encrypted_strings

别说谁变了你拦得住时间么 提交于 2019-12-25 06:46:42
问题 I'm having troubles to extract the IV generated with the encrypt method from encrypted_strings library for a specific password I provide. From the documentation, I see that this method generates a key and iv based on a password using a C library that calls the same method as openssl to generate the key and iv: EVP_BytesToKey. What I'm trying to do is to be able to print the IV for any password I specify so I can port the encryption to another language. Can you think of any method to extract

Encrypt/decrypt string with des cbc mode obj-c

安稳与你 提交于 2019-12-25 05:03:21
问题 hi guys i'm pretty new in obj-c world and i would like know how can I encrypt a string in des? I already tried search but could not find any sample code that could help me the only thing I realized is that there is a class commonCrypt to do what I want but I do not know how to use it my code NSString* key = @"abc43HU0"; NSString *token = @"hellohello"; const void *vplainText; size_t plainTextBufferSize; plainTextBufferSize = [token length]; vplainText = (const void *) [token UTF8String];

How to enable a disabled cipher by default in openssl 1.1.0g for my python client

自作多情 提交于 2019-12-25 00:58:54
问题 I am using python ssl library which is built on openssl. I use Ubuntu which has OpenSSL 1.1.0g. In OpenSSL 1.1.0g the following cipher DES-CBC3-SHA is disabled by default. I need to configure my client with this cipher enabled. I need it for testing. In SSL context, I found some ways that allow enabling some disabled options by default. For example, in this documentation the following negate SSL 3.0 which is disabled by default: ctx = ssl.create_default_context(Purpose.CLIENT_AUTH) ctx

Using DES to encrypt and decrypt a file in Java

回眸只為那壹抹淺笑 提交于 2019-12-24 11:27:02
问题 I'm trying to serialize an object (in this case a simple string), encrypt it, and write it to a file. The encryption seems to work, but the decryption always fails. I've tried searching around, but I can't seem to figure out what I'm doing wrong.. // Create a new key to encrypt and decrypt the file byte[] key = "password".getBytes(); // Get a cipher object in encrypt mode Cipher cipher = null; try { DESKeySpec dks = new DESKeySpec(key); SecretKeyFactory skf = SecretKeyFactory.getInstance("DES