Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of AES encryption in the front end of Mini Program

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the method of AES encryption in the front end of Mini Program", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "Mini Program front-end AES encryption method" bar!

one。 Preface

What is AES encryption: advanced encryption Standard (English: Advanced Encryption Standard, abbreviation: AES), also known as Rijndael encryption method in cryptography, is a block encryption standard adopted by the federal government of the United States. This standard, which is used to replace the original DES, has been analyzed by many parties and is widely used all over the world. After a five-year selection process, the Advanced encryption Standard was issued by the National Institute of Standards and Technology (NIST) in FIPS PUB 197 on November 26th, 2001, and became a valid standard on May 26th, 2002. In 2006, the advanced encryption standard has become one of the most popular algorithms in symmetric key encryption.

In the application scenario of AES encryption, AES encryption can be reversed, and the front and rear ends share a secret key to encrypt and decrypt.

two。 Difficulties:

Mini Program introduces third-party library

The encryption and decryption types of the front and back end match.

three。 Action:

Many people say how Mini Program is introduced into third-party libraries:

Download a file

When 1.exports comes out, exports can expose the file as a module (next time tell the difference between exports, exports defult and model exports)

two。 Reference it in the file used

/ / aes.js file

`/ *

CryptoJS v3.1.2

Code.google.com/p/crypto-js

(C) 2009-2013 by Jeff Mott. All rights reserved.

Code.google.com/p/crypto-js/wiki/License

/ *

Var CryptoJS=CryptoJS | | function (init p) {var d = {}, s=function () {}, s=function () {}, create:function () {var a=this.extend (); a.init.apply () {var a=this.extend (); a.init.apply () Return a}, init:function () {}, mixIn:function (a) {for (var c in a) a.hasOwnProperty (c) & (This [c] = a [c]); a.hasOwnProperty ("toString") & & (this.toString=a.toString)}, clone:function () {return this.init.prototype.extend (this)}}

R=l.WordArray=t.extend ({init:function (Agrad c) {a=this.words=a | | []; this.sigBytesSigBytesAccording to return 4a.length}, toString:function (a) {return (a | | v) .stringify (this)}, concat:function (a) {var clockthis.wordscatalogues.sigBytesTransmissiona.sigBytestransthis.clamp (); if (j% 4) for (var kendtthis.clamp () > 2] | = (e [k > > 2] > > 24-8* (k% 4) & 255) 2] = Else c.push.apply (c > > 2) & = 42949672952] > 24-8 * (j% 4) & 255position e.push ((k > 4). ToString (16)); e.push ((karm15) .toString (16))} return e.join ("")}, parse:function (a) {for (var cymna.toString = [], jobsj > 3] | = parseInt ((j)

R=r.MD5=v.extend ({_ doReset:function () {this._hash=new w.init ([1732584193 402323341752583102) 271733878])}

_ doProcessBlock:function (Q _ quotient n) {for (var axion 16 > a _ polio ~ +) {var cymbals _ quotient [c] Q [c] = (e > 24) & 16711935 | (e > 8) & 4278255360} var axithis.roomhash.wordsMagi [Numb0], eQuq [Noble 1], Juncq [Nation1], Kenzq [Nonium3], Zhonq [Noni4], rqq [nong5], Tereq [nong6], Wendq [nong7], vroomq [nong8], Aqumq [nong9], Bronq [Nation10], Cymbiq [Noble 11], upriq [Noble 12], Denzq [Noble 13], Equmq [naught14], xLiuq [nong15], Funca [0], Ma [1], Ga [2], Ha [3], FPP (FG) [0]), hlemp (hgravity frecinct, mrecedence, ereparce, 12reireb [1]), glemp (grecinct, hregory, mrecaly, jpwick, 17repartee, b [2]), mtransip (mrecaly, pint, pause, 22lb, [3]), Flemp (frecery, mparg, parry, z7pr [4]), hemerp (hfine, frecrium, mrecore, gpentry 12reb [5]), gpenp (gpentry, hminute, paramel, gmparist, and 17pjb [6]) Macrop (m _ recorder g _ r _ 22 _ b [7])

Flemp (frecinct, grecinct, herry7, repartee, b [8]), hemerp (grecinct, frecedence, pyrricium, pyrrine, pyrrine, pyrrolium, pyrrolium, pyrrolidine, pyrrolium, pyrrolium, pyrrolidine, pyrrolium, pyrrolium, 17 relegation b [14]), mexamd (mrecedence grecinct, frecrence22reparentb [15]), fendd (frecedence, mrecedence, 5retractile b [16]), hcorrecd (hrecedence, mrecedence, 9pr [17]), gcorrecd (grecalhforme, pharec, 14reb [18]), mendd (mleadership, grecaland, 20b [19]), femerd (fmaemrect, grecory, hminute 5b [20]), hemerd (h) [21]), gendarmerd (grecedompence14 [22]), mcorrecd (mgrafreced20 [23]), frecedd (frecedommgrafforma5 [24]), hcorrecd (hchiefree9 [25]), gcorrecd (grecedompence14] b [26]), mtransid (mrecedence, mgPerfew20), mgramd (mrecegPerson20) B [27]), frecd (frech m, g, g, d, 5, d, h, e, h, e, e, h, e, g, d, d,

Merrill grecinct, jrecrum, 9pr, b [29], gpend (ggrafrect, frecinct, wpjrep, 14rep, b [30]), mgramd (mgravity, grecinct, freground, 20penny, b [31]), femerl (frecinct, frecorder, 4pr, b [32]), hemerl (hrecory, frecorder, mpender, 11pr, b [33]), gendl (greco, hpart, mpender, mpender, 16pime, [34]), mskill (mminute, ghparter, freground, 23). (B [35]), femerl (frecedence, mrecedence, 4reireb [36]), hemerl (grecinct, frecince11), gemerl (ggrafrect, frecince16 [38]), mmirl (mmaegforint, fmae23 [39]), femerl (fmaemLindlDLLLL4, [40]), hemerl (frector, mlast, glast, cpene, 11Powerb [41]), gemerl (grech Frecinct (mrecedence), mrecol (mgrad), (freground), (()), (), (()), (()), ( B [48]), hagles (hminefield frecincegrectionwrection10remieb [49]), grecs (grecincehparfrectorm)

Erecover15 [50]), MachiaS (mrecedence grecinct, frecince21reparentb [51]), femers (frecincemgrafrecy, hrecedence 6pr b [52]), hrecores (hrecorder frecince10lle b [53]), gmirals (grecalart hforme, pr 15reb [54]), mbears (mrecrum grecinct fjor21parb [55]), frecs (fpense mpjmpjmpjjpmjpmpjjpmpjpmpmpmpjjjpmpmpmpmpjpmpjpmpjpmpjpmpjpmpjpmpjpmlb [56]). [57]), Glasgow (GWH), MQ (MWH), HQ (MWH), HQ (HQ), HQ (GQ), GCS (GJH), MQ (MJ), MQ (MGTL) A [0] = a [0] + f | 0 var a [1] = a [1] + m | 0 a [2] = a [2] + g | 0 a [3] = a [3] + h | 0}, _ Shia () {Bathis. Exact dataBytesprecept 8this.flagnDataBytesprecinct cymbal 8b.sigBytestransn [c > > 5] | = 128 > 98) & 4278255360ten n [(cym64 > > 98) & 4278255360X bsig.BytesExample 4 (n.length+1); this._process (); Bathis. [a], n [a] = (c > 24) & 16711935 | (c > 8) & 4278255360 return b}, clone:function () {var b=v.clone.call (this); b._hash=this._hash.clone (); return b}}); t.MD5=v._createHelper (r); t.HmacMD5=v._createHmacHelper (r)}) (Math)

(function () {var upright CryptoJS repertoire prunu.libreaching.BaseReclamp.WordArrayreparchp.WordArrayrewangp.EvpKDFendd.extend ({cfg:d.extend ({keySize:4,hasher:p.MD5,iterations:1}), init:function (d) {this.cfg=this.cfg.extend (d)}, compute:function (dart r) {for (var pairthis.cfgparamentp.hasher.create (), b=l.create (), uppb.wordsparamentp.keySizeParticipp.iterationsusu.length)

L)}} ()

| CryptoJS.lib.Cipher | | function (u) {var paired CryptoJSrec dumbp.librewayd.BaseRecycld.WordArrayRetrospecd.BufferedBlockAlgorithmParticipp.algo.EvpKDF codificd.Cipherand.extend ({cfg:l.extend (), createEncryptor:function (eQuery a) {return this.create (this._ENC_XFORM_MODE,e,a)}, createDecryptor:function (eQuery a) {return this.create (this._ENC_XFORM_MODE,e,a)}, init:function B) {this.cfg=this.cfg.extend (b) This._xformMode=e;this._key=a;this.reset ()}, reset:function () {t.reset.call (this); this._doReset ()}, process:function (e) {this._append (e); return this._process ()}

Finalize:function (e) {e&&this._append (e) Return this._doFinalize ()}, keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function (e) {return {encrypt:function (breco kpagh d) {return ("string" = = typeof k?c:a) .scot (ereco breco kpenh d)}, decrypt:function (breco kpenh pint d) {return ("string" = = typeof k?c:a) .decrypt (erecaline breco kpenh d)})) D.StreamCipher=v.extend ({_ doFinalize:function () {return this._process (! 0)}, blockSize:1}); var breadth. Modee = {}, x=function (eLECH arecthis) {var clockthis. Infractivating clockthis.roomivory uvana clockthis.cake Blockthisfor (var dumb0td.

C [d]}, Q = (d.BlockCipherMode=l.extend ({createEncryptor:function (erecogenca) {return this.Encryptor.create (erecogenca)}, createDecryptor:function (erectus a) {return this.Decryptor.create (erecogance a)}, init:function (erecogy a) {this._cipher=e;this._iv=a})) .extend (); q.Encryptor=q.extend ({processBlock:function (erecogance a) {var bicithis. Blockciphermcr. BlockSizeterx.call (this,e,a,c) B.encryptBlock (eMagol a); this._prevBlock=e.slice (aMagnea)}}); q.Decryptor=q.extend ({processBlock:function (eRecience a) {var bizthis.blockSizeFinder dtraine.slice (adre arecc); b.decryptBlock (eMagne); x.call (this)

)); this._prevBlock=d}}); baccounb.CBCaccounqmitQ = (p.pad = {}) .Pkcs7 = {pad:function (Areco b) {for (var cymbium 4brecedicclica.sigBytes% cedarinc8] 255] > > 24] > 16copyright 255] > 813255] 24] ^ x [lk > > 16room255]] ^ Q [lk >

8q255] ^ n [l [k & 255]]}, encryptBlock:function (arecore b) {this._doCryptBlock (arect bforce this.harmkeySchedule)}, decryptBlock:function (arect c) {var donga [cedl]; a [cedl] = a [cedar 3]; a [cedar 3] = dash this.imperdoCryptBlock (aQuery cis. InvinvKeySchedule BJX); dpena [cedl]; a [cedule 1] = ac [c + 3] A [Cephal3] = d}, _ doCryptBlock:function (var massively this.classnRoundsreposeGranga [b] ^ c [0], Hallela [Bene1] ^ c [1], Kaia [Bene2] ^ c [2], Natura [Bene3] ^ c [3], pamph4Participated raster 1X r > > 24] ^ e [h > 160255] ^ l [Noble 255] ^ c [pamphlet +], scoffd [h > 24] ^ e [k > 16q255] ^ j [n > 8q255] ^ l [g255] ^ c [n > > 8q255] ^ l

D [k > 24] ^ e [n > 16x 255] ^ j [g > 8x 255] ^ l [hype 255] ^ c [pause +], naught [n > 24] ^ e [g > 16x 255] ^ j [h > 8x 255] ^ l [k > 8x 255] ^ c [p = (f [g > > 24] > 160255] > 8255] > 24] > 160255] > 8255] > 24] > 160255] > 8255] > 24] > 160255] > 8255] > 24]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report