The safest encryption algorithm (from the blog with less temperature)

Source: Internet
Author: User
Tags key
Security | encryption | Algorithm in cryptography, there is an ideal encryption scheme, called a secret garbled this (one-time pad). One-time pad algorithm has the following requirements: 1, the key must be randomly generated 2, the key can not be reused 3, the key and the length of the cipher is the same. One-time pad is the safest encryption algorithm, the two sides once the security exchange of the key, the exchange of information after the process is absolutely safe. This algorithm has been used in a number of highly confidential occasions, it is said that the United States and the former Soviet Union hotline, the former Soviet spy are used one-time pad to encrypt the way. No matter how long the supercomputer works, no matter how many people, what methods and techniques, how much computing power, it is impossible to crack. A one-way implementation of a secret, as follows:public class onetimepadutil {    public static  Byte[] xor (byte[] bytes, byte[] keybytes)  {         if  (keybytes.length != bytes.length)  {             throw new illegalargumentexception ();         }        byte[] resultbytes = new  byte[bytes.length];        for  (int i = 0;  i < resultbytes.length; ++i) &NBSP;{&NBSP;&NBSP;&NBSP;&NBSP;&NBsp;       resultbytes[i] =  (Byte)   (keybytes[i] ^  Bytes[i]);        }         RETURN&NBSP;RESULTBYTES;&NBSP;&NBSP;&NBSP;&NBSP}} Use the example:string plaintext =  "temperature is less"; string keytext =  "Password"; byte[] plainbytes = plaintext.getbytes ();byte[]  Keybytes = keytext.getbytes (); assert plainbytes.length == keybytes.length;//encryption byte[]  cipherbytes = onetimepadutil.xor (plainbytes, keybytes)/Decrypt Byte[] cipherplainbytes  = onetimepadutil.xor (cipherbytes, keybytes);
This is the simplest encryption algorithm, but also the most secure secret algorithm. The day before yesterday and friends to discuss this issue, so wrote this article.


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.