des

字符串加密写入文本文件(01)

别来无恙 提交于 2019-12-03 20:28:05
该方法经过测试,并应用到项目了。 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace WindowsFormsApplication1 { public class FileEncryptDecrypt { /// <summary> /// 加密字符【长度必须为8】 /// </summary> private static string _Key = "TBQDLKSW"; /// <summary> /// 将密钥加密写入到文件 /// </summary> /// <param name="sOutputFilename">文件路径</param> /// <param name="content">文件内容</param> /// <param name="sKey">密钥</param> private static void EncryptFile(string sOutputFilename, string content, string sKey) { using

Converting Key to String and back to Key Java

Deadly 提交于 2019-12-03 17:58:05
问题 so I'm trying to convert a Key into a string so I can display it with System.out, and then I want to convert it back to a Key. I am able to convert it to a string with BASE64Encoder, but I'm having problems converting it back. Here is my source code: public class Encryption extends Applet { Key keyOrig; BASE64Decoder decoder = new BASE64Decoder(); BASE64Encoder encoder = new BASE64Encoder(); public void init() { try { keyOrig = generateKey(); String keyString = encoder.encode(keyOrig

Brute forcing DES with a weak key

折月煮酒 提交于 2019-12-03 12:16:40
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 coincide with the corresponding byte in my key, except for the least significant bit which is not used in DES

Replicate Java's PBEWithMD5AndDES in Python 2.7

好久不见. 提交于 2019-12-03 09:08:45
If it's not immediately obvious, let me start by saying I am not a crypto person. I have been tasked with replicating the behavior of Java's PBEWithMD5AndDES (MD5 digest with DES encryption) in Python 2.7. I do have access to Python's cryptography toolkit PyCrypto. Here is the Java code whose behavior I am trying to replicate: import java.security.spec.KeySpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import java.security.spec.AlgorithmParameterSpec; import javax.crypto.spec.PBEParameterSpec; import javax.crypto.Cipher; import

PyCrypto: Generate RSA key protected with DES3 password

南楼画角 提交于 2019-12-03 08:13:46
I have been able to create a RSA key protected by password with DES3 (well... I think because I'm very new to this encryption world) by using the command: openssl genrsa -out "/tmp/myKey.pem" -passout pass:"f00bar" -des3 2048 Now, I would like to do that inside a Python script, using PyCrypto, if possible. I have seen this message , which seems to discourage the use of PyCrypto to do that. Is it still like that? Of course I can always call os.execute , and execute the above command, but I'd consider that "cheating" :-) . I'm pretty much doing this to learn PyCrypto. Thank you in advance.

SSLHandshakeException: Handshake failed on Android N/7.0

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working on an app for which the (power)users have to set up their own server (i.e. nginx) to run the backend application. The corresponding domain needs to be configured in the app so it can connect. I've been testing primarily on my own phone (sony z3c) and started developing for 5.1. Later I received an update for 6.0 but still maintained a working 5.1 inside the emulator. Not too long ago, I started to work on an AVD with an image for 7.0 and to my suprise it won't connect to my server, telling me the ssl handshake failed. My nginx

SSLHandshakeException: Received fatal alert: handshake_failure when setting ciphers on tomcat 7 server

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Tomcat7 web-server which I tried to configure to accept secure connections by adding this connector to the server.xml file: I'm using a self-signed certificate generated using this command: %JAVA_HOME%/bin/keytool -genkeypair -keystore c:\opt\engine\conf\tc.keystore -storepass o39UI12z-keypass o39UI12z-dname "cn=Company, ou=Company, o=Com, c=US" -alias server -validity 36500 On the client side I have a spring application that connects with the server using RestTemplate . On application context startup I initalize the restTemplate

Enabled ciphers on Ubuntu OpenJDK 7

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I wrote the following Java program to dump the enabled ciphers in the JVM: import java.security.KeyStore; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManagerFactory; public class ListCiphers { public static void main(String[] args) throws Exception { SSLContext ctx = SSLContext.getInstance("TLSv1"); // Create an empty TrustManagerFactory to avoid loading default CA KeyStore ks = KeyStore.getInstance("JKS"); TrustManagerFactory tmf = TrustManagerFactory

SSLHandshakeException: Received fatal alert: handshake_failure when setting ciphers on tomcat 7 server

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Tomcat7 web-server which I tried to configure to accept secure connections by adding this connector to the server.xml file: <Connector SSLEnabled="true" acceptCount="100" connectionTimeout="20000" executor="tomcatThreadPool" keyAlias="server" keystoreFile="c:\opt\engine\conf\tc.keystore" keystorePass="o39UI12z" maxKeepAliveRequests="15" port="8443" protocol="HTTP/1.1" redirectPort="8443" scheme="https" secure="true" sslProtocol="TLS"/> I'm using a self-signed certificate generated using this command: %JAVA_HOME%/bin/keytool

Given final block not properly padded

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to implement password based encryption algorithm, but I get this exception: javax.crypto.BadPaddingException: Given final block not properly padded What might be the problem? (I am new to Java.) Here is my code: public class PasswordCrypter { private Key key; public PasswordCrypter(String password) { try{ KeyGenerator generator; generator = KeyGenerator.getInstance("DES"); SecureRandom sec = new SecureRandom(password.getBytes()); generator.init(sec); key = generator.generateKey(); } catch (Exception e) { e.printStackTrace(); } }