[AES]
A symmetric encryption algorithm, used by DES.
For more information about encryption, see Java encryption and decryption symmetric encryption algorithm asymmetric encryption algorithm MD5 BASE64 AES RSA
[Code]
There are many codes. Some of them are not the content code of this Article. Let's take a look at them for details.
Package com. uikoo9.util. encrypt; import java. math. bigInteger; import java. security. messageDigest; import java. security. secureRandom; import javax. crypto.
Check the password suites supported by the windows system.
On Windows 10 clients and Windows server 2016 servers, you can use the powershell command to obtain a list of supported cipher suites and disable enabling the corresponding cipher suites.
# Command link: https://technet.microsoft.com/zh-cn/library/dn931990.aspx
# List of packages supported by the system obtained by win10 server2016Get-TlsCipherSuite
key cryptosystem.General design principles for block cipher security:The packet length n should be large enough to prevent a poor search attack from being effective against clear text.The key space K should be large enough to prevent a poor search attack on the key from working.Chaos : The dependency between ciphertext and plaintext and the key is so complicated that this dependency is not available to the cipher
fileinputstream (f );Objectinputstream in = new objectinputstream (BW );Key = (key) in. readobject ();In. Close ();BW = NULL;}F = NULL;} Catch (exception e ){Debug (E. getmessage ());}Return key;}
Here we directly store the key object in a file. Of course, the key object can also be stored in bytes, but it may be a little troublesome!
Now the key problem has been solved. The next step is to write encryption and solve the problem.
// STR byte array to be encryptedPublic static byte [] dataencryp
by the certificate chain.
the name of the cipher suite. Cipher Suites Describe the kind of encryption protection that is used by connections in a particular session.
Peer host. all connections for a single session are made between the same two hosts. The address of the host at the other end of the connection is available.
You can explicitly invalidate the session. You can also implicitly inval
With the development of symmetric cipher, the DES data Encryption Standard algorithm, because of its small key length (56 bits), has not adapted to the requirements of today's distributed open Network for data encryption security, so 1997 NIST publicly recruited new data encryption Standard, namely AES[1]. After a tricycle selection, the Rijndael algorithm submitted by the Belgian Joan Daeman and Vincent Rijmen was proposed as the final algorithm for
encryption algorithm the development not to be optimistic.
The DES algorithm provides four models of CBC, OFB, CFB, and ECB, and the MAC is based on ECB implementations.
"Java uses 3DES encryption to decrypt the process"
① incoming common agreed key (keybytes) and algorithm (algorithm) to build Secretkey Key Object
Secretkey Deskey = new Secretkeyspec (keybytes, algorithm);
② instantiate the Cipher object based on the algorithm.
technology2.1 Encryption algorithmSymmetric cryptography is the same as the encryption and decryption key, or it is known that one can easily deduce another. So the two sides of communication must agree on a key before communicating. In the symmetric encryption system, the key must be kept secret, and any third party can easily decrypt the cipher if it gets the key.Asymmetric cryptography is the communication between the two sides encryption key and
. writeobject (pbkey );// Save the key to the file
File = new file ("digitalenvolope", "rs1_vate. dat ");Fileoutputstream outprivate = new fileoutputstream (File );Objectoutputstream privateout = new objectoutputstream (outprivate );PrivateOut. writeObject (prKey );} Catch (Exception ex ){Logger. getLogger (GenKey. class. getName (). log (Level. SEVERE, null, ex );}
}
}
3. encrypt important data with the DES key
/** To change this template, choose Tools | Templates* And open the template in the
1. MD5 encryption, which is often used to encrypt user names and passwords.
Protected byte [] encrypt (byte [] OBJ )...{Try ...{Messagedigest MD5 = messagedigest. getinstance ("MD5 ");Md5.update (OBJ );Return md5.digest ();} Catch (nosuchalgorithmexception e )...{E. printstacktrace ();}}2. Sha encryption: similar to MD5, but the two algorithms are different.
Protected byte [] encrypt (byte [] OBJ )...{Try ...{Messagedigest Sha = messagedigest. getinstance ("Sha ");Sha. Update (OBJ );Return Sha.
This article mainly introduces the des encryption and decryption code sharing that is compatible with PHP and Java. it is suitable for cases where the server is written in JAVA and the client is written in PHP and des encryption and decryption is required, for more information about php code, see:
Java code:
Package com. test; import it. sauronsoftware. base64.Base64; import java. security. key; import java. security. secureRandom; import java. security. spec. algorithmParameterSpec; impor
Asp.net and java are used to encrypt and decrypt des, asp. netjavades
Recently, a new project was developed in java. The old project is asp.net, and the interface transmission requires des encryption and decryption. I checked some information on the Internet and most of the information can't be used, after debugging and processing, the specific code is as follows:
The key must be 8 bits.
///
The corresponding java method is as follows:
Package com. testspring;
Import javax. crypto.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.