Ask for a reversible encryption algorithm that requires a bit of high

Source: Internet
Author: User
Requirements:
1. The length of the encryption is as long as the length before encryption
2. Only letters from A to Z and numbers 0 to 9 are allowed in the encrypted string
3. According to the secret key can be counted back
The string before encryption is also a combination of letters and numbers
such as the string before encryption: Us3kqvu


Reply to discussion (solution)

You can try Caesar encryption and fence encryption, or use both of these 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: 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: Us3kqvu
is there a large probability of the repetition of this encryption and decryption method

Caesar password is implemented by moving character Map mappings, there is no possibility of duplication in theory

so-called mobile Character Map mapping is like
original ABCD
Move distance 4
Ciphertext efgh

One byte has 8 bits, 6 bits has 2^6=64 Possible, the letter + number Total 62
So there is a mapping table can be compressed into 6 bits

6 bit to 6 bits of the bit operation is more, any choice, and then reverse mapping to alphanumeric

The process above 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.