"WeChat applet development Tutorial" menu content linkage & MD5 encryption

Source: Internet
Author: User
Tags decrypt hmac md5 encryption
This is a creation in Article, where the information may have evolved or changed.

1****, * * * * * * * Menu Content linkage
Small program can not get the width of the element, location information, only through the background calculation, but there is a large machine error, do not know what a good solution?



So, on the left side is the menu bar, the right side is the main content, click on the left menu, the right to slide to the corresponding position, the right sliding process, will also change the left side of the menu selected state. The implementation of my plan:

All element size units with RPX;
Get the total height of the right sliding area (in px) via the e.detail.scrollheight of Scrollbind (e)
Calculates the actual height (px) by the ratio of the height of the item to the height of the title.
Change the body content position by modifying the scrolltop (unit px)

This still exists 1px-100px error, the more items, the cumulative error after the greater, there is no better solution?
A: tested, and indeed with the Scroll-view Scroll-to-view features can be resolved:
Modified in wxml****:

Changes in the js**** file:

Added in page data:

menuType:['food','dust','bowl','cages','toys','tools'],toView:'cages',

Then modify the following function:

selectMenuAct: function (e) {//typenamevar id = e.target.dataset.id;var tType=this.data.menuType[id];console.log(e),this.setData({  scrollNum: id,  toView: tType  //scrollTop: this.data.heightList[id]});},

The test environment is passed.

The Scroll-into-view value should be a child element ID (the ID cannot begin with a number). Sets which direction is scrollable, and in which direction scrolls to that element.

2****, small program ****md5**** encryption
Generally, many languages have MD5 encrypted libraries.
If you are referring to data encryption, for fear that the data plaintext is not secure, I recommend using base64 + some prefixes or suffixes to encrypt, and then upload the data to the server, the server then decrypt and then remove the prefix. For example, the plaintext is ABC, you can add a prefix, become 123abc, and then encrypt the MTIZYWJJ and then send out, and then decrypt the line.
General MD5 encryption is irreversible. And base64 can encode and decode, as follows:

package mainimport (    "fmt"    "github.com/hunterhug/GoSpider/util")func main() {    s := "abc"    prefix := "123"    base64e := util.Base64E(prefix + s)    fmt.Println("加密:" + base64e)    fmt.Println("再解密:" + util.Base64D(base64e))}

Results

Encryption: MTIZYWJJ
Re-decryption: 123ABC

Introduction to Baidu Encyclopedia: BASE64 encoding can be used to pass longer identity information in an HTTP environment. For example, in the Java Persistence System hibernate, Base64 is used to encode a long unique identifier (typically 128-bit uuid) as a string that is used as a parameter in an HTTP form and an HTTP GET URL. In other applications, it is often necessary to encode binary data as appropriate in the form of URLs (including hidden form fields). At this time, the adoption of BASE64 encoding is not only short, but also has the non-readability, that is, the encoded data will not be directly visible to the naked eye.

My Golang language The cryptographic libraries that I encapsulate are generally the same:

/*copyright by Gospider author. Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the Lic Ense. Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or Agreed to writing, softwaredistributed under the License are distributed on a "as is" basis,without warranties OR Condi tions of any KIND, either express or implied.    See the License for the specific language governing permissions andlimitations under the License.*/package utilimport ( "Crypto/hmac" "Crypto/md5" "crypto/sha256" "Encoding/base64" "Encoding/hex" "FMT" "Net/url" "strings ")//HMAC with the SHA256 http://blog.csdn.net/js_sky/article/details/49024959func ComputeHmac256 (Message string, Secret string) string {key: = []byte (Secret) H: = HMAC. New (sha256. New, Key) H.write ([]byte (Message)) return base64. Stdencoding.encodetostring (H.sum (nil))}//create MD5 StringfuNC Strtomd5 (s string) string {h: = MD5. New () H.write ([]byte (s)) rs: = Hex. Encodetostring (H.sum (nil)) return Rs}func Md5 (str string) string {return Strtomd5 (str)}//string base64 encrypt func base64e (u Rlstring string) string {str: = []byte (urlstring) Data: = base64. Stdencoding.encodetostring (str) return data}//string base64 decrypt func base64d (urlxxstring String) string {data, err: = Bas E64. Stdencoding.decodestring (urlxxstring) if err! = Nil {return ""} s: = Fmt. Sprintf ("%q", data) s = strings. Replace (S, "\" "," ",-1) return S}//url escapes the Func Urle (s string) string {return URL. Queryescape (s)}//url Jiayi func Urld (s string) string {s, e: = URL. Queryunescape (s) if E! = nil {return e.error ()} else {return s}}

Most sites now have HTTPS turned on to ensure data security.

Related Article

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.