Asymmetric encryption algorithms (public and private)

Source: Internet
Author: User
Tags decrypt asymmetric encryption

  The asymmetric encryption algorithm requires two keys for encryption and decryption, which are public keys (publicly key, referred to as public key) and private key, or secret key (private key).

The public key and private key are a key pair (a public key and a private key) obtained through an algorithm, the public key is the part of the key pair, and the private key is a non-public part. Public keys are typically used to encrypt session keys, verify digital signatures, or encrypt data that can be decrypted with the corresponding private key. The key pairs obtained by this algorithm are guaranteed to be unique worldwide. With this key pair, if one of the keys is used to encrypt a piece of data, it must be decrypted with another key. For example, the public key to encrypt the data must be decrypted with the private key, if the private key encryption must also be decrypted with the public key, or decryption will not succeed. (cited here Baidu Encyclopedia of the entry explanation)

Let's talk about how it's used.

First introduce the Jsencrypt file in the page (you can use CDN acceleration)

Next you can use the key generation tool to generate the public and private keys (the recommended cryptographic decryption tool)

Full Case (PS: Public and private keys can be generated using the key generator tool):

<!     DOCTYPE html>Public_key="-----BEGIN Public KEY-----"+"migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqd3ohpxaoospobj3cxh31t1ke5i"+"B5dfcub59vx7fxlifdeiknr1nkak+yqltvf/ricaot8ni/ngbujxp19nojplues2"+"Kqavo5h8f7wow2okhwtcggeb+mmol11qckg1ngl7czteu+2t/o1a4wyzvg6xusxj"+"+hpnc2/15d410bk94qidaqab"+"-----END Public KEY-----"; VarPrivate_key="-----BEGIN PRIVATE KEY-----"+"Miicdwibadanbgkqhkig9w0baqefaascamewggjdageaaogbapc6gnfo6hkk5snc"+"Jehfvpwqtkhvkn8jqhn29ft/gwiumqisdhweqct5hcw1ux9ehxqhpyel80yfqngn"+"X2eioktr6zasppwjkfwxty7daiqfc0iyyrv4wyixxwoiobwcaxtxm0s77zp87udj"+"Bjo+dpdsxcn4c+dzb/xkpjxrsr3hagmbaaecgyb3/nkrmwvraso9lawpyn16psto"+"Myzoss5jpe01+twxvhcigvsvj26ww46zqs1aiufn8o+vot69cjyuvdlfkotzz7nc"+"A8ah/8cvjeanjd8dgmzojjifpwxp0wmyta09sdcgknkbmmldx1mhaaua7ozy81gy"+"8di0dtftlv3ow4ycbqjbap5ofbzoorq7spelk+w/ojhn5kf5ym5qzc2klpokstw4"+"Uuiboa//pbdpvtzz9ujsqf/d6sglbcednd6ogg368pccqqd434s1bnbc45xtec/r"+"Zorb8ed3qhdifrxfalty+kppagup9quu+m9ymqwvsysw7uzrhkqpqjsghfbo9exx"+"nvphakeark7z4lwnxpgq508tdnga5by3vgv1kn77igvxljwy2rfr5kzh4dr7142p"+"Gci25caiimvrcigg4owxkubphlenzqjbamsvpzw5e13ilp7aplbq8np5ghqbdnka"+ " il5f3exqncl+fls61gqqaet2b8let0pxpaabukb36dhdkvqtcpmego0cqerzipg1 "  +  " F1UEPVCSDQCRJ3TZ6CKERSWZJUMUZ10S+V8WIKZN1DXTYOK4QEDAEMR81LJPSLDW  " + "  9soceokudnj4nla=  " + " -----END PRIVATE KEY----- "; Use the public key to encrypt var  encrypt  = new  jsencrypt (); Encrypt.setpublickey (Public_key); var  encrypted  =  encrypt.encrypt ( '  Nothing is difficult, I'm afraid of a conscientious  ' );//encryption  Console.log (encrypted); Decryption with the private key var  decrypt  = new  jsencrypt (); Decrypt.setprivatekey (Private_key); var  uncrypted  =  Decrypt.decrypt (encrypted);//Decrypt  Console.log (uncrypted) </script></body> 


For more information on the use of Jsencrypt files, see http://www.bootcdn.cn/jsencrypt/readme/

Asymmetric encryption algorithms (public and private)

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.