A reversible encryption algorithm with high requirements

Source: Internet
Author: User
A reversible encryption algorithm requires high requirements:
1. the encrypted length is the same as the encrypted length.
2. only letters from a to z and numbers from 0 to 9 are allowed in the encrypted string.
3. you can calculate it back based on the key.
The strings before encryption are also a combination of letters and numbers.
For example, the string before encryption: us3kqvu


Reply to discussion (solution)

You can try Caesar encryption and fence encryption, or use both methods.

Caesar password

$ Key = '3ae '; $ s = caesar_encode ('us3kqvu', $ key); echo "$ s \ n"; echo caesar_decode ($ s, $ key ); function caesar_encode ($ s, $ k) {$ k = "$ k"; for ($ I = 0; $ I
 
  
Ciphertext: ljubhml
  
Original article: us3kqvu

Caesar password

$ Key = '3ae '; $ s = caesar_encode ('us3kqvu', $ key); echo "$ s \ n"; echo caesar_decode ($ s, $ key ); function caesar_encode ($ s, $ k) {$ k = "$ k"; for ($ I = 0; $ I
   
    
Ciphertext: ljubhml
    
Original article: us3kqvu
Is there a high probability that this encryption/decryption method is repetitive?

The Caesar password is implemented by moving the sequence table ing. Theoretically, there is no possibility of repetition.

The so-called moving two-dimensional table ING is like
Original article abcd
Moving distance 4
Ciphertext efgh

One byte has 8 bits, and 6 bits can be 2 ^ 6 = 64, with a total of 62 letters and numbers
Therefore, a ing table can be compressed to six digits.

6-to 6-bit bitwise operations are much more. Ren Jun chooses, and then reversely maps to letters and numbers.

The above process is reversible.

Caesar encryption and fence encryption

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.