บทความนี้อธิบายอัลกอริทึมการสร้างคีย์ AES ที่ใช้โดย Java แบ่งปันสำหรับการอ้างอิงของคุณดังนี้:
นำเข้า Java.security.nosuchalgorithmexception; นำเข้า Java.security.securerandom; นำเข้า Javax.crypto.keyenerator; {ลอง {keygenerator kg = keygenerator.getInstance ("AES"); // เพื่อสร้างจำนวนบิตเพียงแค่แก้ไขที่นี่ 128, 192 หรือ 256 คีย์ inary คือ "+s.length ()*4);} catch (nosuchalgorithmexception e) {e.printstacktrace (); System.out.println ("ไม่มีอัลกอริทึมนี้"); 128, 192 หรือ 256 // Securerandom คือการสร้างลำดับหมายเลขสุ่มที่ปลอดภัย, รหัสผ่าน, getBytes () เป็นเมล็ด kg.init (128, securerandom (password.getbytes ()); ความยาวของคีย์ไบนารีคือ "+s.length ()*4);} catch (nosuchalgorithmexception e) {e.printstacktrace (); System.out.println ("ไม่มีอัลกอริทึมนี้")}} / ** * byte อาร์เรย์แปลงเป็น hex string * @param bytes * @return * / สตริงคงที่สาธารณะ bytetohexstring tohexstring (bytes [i]); if (strhex.length () <2) {sb.append ("0" + strhex);PS: เพื่อนที่สนใจในการเข้ารหัสและถอดรหัสสามารถอ้างถึงเครื่องมือออนไลน์ของเว็บไซต์นี้:
การตรวจจับความปลอดภัยของรหัสผ่านออนไลน์:
http://tools.vevb.com/password/my_password_safe
เครื่องกำเนิดรหัสผ่านที่มีความแข็งแรงสูง:
http://tools.vevb.com/password/createstrongpassword
Thunder, Express และ Tornado URL เครื่องมือการเข้ารหัส/ถอดรหัส:
http://tools.vevb.com/password/urlrethunder
เครื่องมือเข้ารหัสอัลกอริทึมแฮช/แฮชออนไลน์:
http://tools.vevb.com/password/hash_encrypt
MD5 ออนไลน์/hash/sha-1/sha-2/sha-256/sha-512/sha-3/ripemd-160 เครื่องมือเข้ารหัส:
http://tools.vevb.com/password/hash_md5_sha
ออนไลน์ sha1/sha224/sha256/sha384/sha512 เครื่องมือเข้ารหัส:
http://tools.vevb.com/password/sha_encode
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรม Java ของทุกคน