liziyu 发布的文章

_)1)@ISS145VH{7)I7CDHTP.png
(M@9@2@~{VX{STI5K$IJ79Q.png
G8QNXEFJ1`K~MX2Q4[M4%FP.png
O058[(D}7(WLHM4~2J{$6PF.png
XV5Z{2IF2EC7C[WF_L}2$TT.png

绕过序列号认证。

function decodeCode(encrypt: string): string {
    const format = (encrypt: string, length: number, offset: number) => {
      const content = ((array, offset) => {
        const max = array.length - offset;
        if (max <= 0) {
          return array;
        }
        const result = new Array(array.length);
        for (let i = 0; i < array.length; i++) {
          if (i < offset) {
            result[i] = array[max + i];
          } else {
            result[i] = array[i - offset];
          }
        }
        return result;
      })(encrypt.split(''), offset).join('');
      const sb: string[] = [];
      let start = 0;
      while (start < content.length) {
        let end = start + length;
        if (end > content.length) {
          end = content.length;
        }
        const item = content.substring(start, end);
        sb.push(item.split('').reverse().join(''));
        start = end;
      }
      return sb.join('');
    };
    const KEY_ENCRYPT =
      'BAFEDIHGLKJONMRQPUTSXWVaZYdcbgfejihmlkponsrqvutyxw10z432765+98/C';
    const index = encrypt.indexOf('=');
    const body = index === -1 ? encrypt : encrypt.substring(0, index);
    const suffix = index === -1 ? '' : encrypt.substring(index);
    const temp = format(body, 12, 3) + suffix;
    const input = temp.replace(/[^A-Za-z0-9\+\/\=]/g, '');
    const KEYS = format(KEY_ENCRYPT, 3, 1) + '=';
    let output = '';
    let chr1: number, chr2: number, chr3: number;
    let enc1: number, enc2: number, enc3: number, enc4: number;
    let i = 0;
    while (i < input.length) {
      enc1 = KEYS.indexOf(input.charAt(i++));
      enc2 = KEYS.indexOf(input.charAt(i++));
      enc3 = KEYS.indexOf(input.charAt(i++));
      enc4 = KEYS.indexOf(input.charAt(i++));
      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;
      output = output + String.fromCharCode(chr1);
      if (enc3 != 64) {
        output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
        output = output + String.fromCharCode(chr3);
      }
    }
    output = ((utftext) => {
      let string = '';
      let i = 0;
      let c = 0;
      let c2 = 0;
      let c3 = 0;
      while (i < utftext.length) {
        c = utftext.charCodeAt(i);
        if (c < 128) {
          string += String.fromCharCode(c);
          i++;
        } else if (c > 191 && c < 224) {
          c2 = utftext.charCodeAt(i + 1);
          string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
          i += 2;
        } else {
          c2 = utftext.charCodeAt(i + 1);
          c3 = utftext.charCodeAt(i + 2);
          string += String.fromCharCode(
            ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)
          );
          i += 3;
        }
      }
      return string;
    })(output);
    return output;
  }

var addresses []model.Address
if ret := s.db.WithContext(ctx).Model(&model.Address{}).
    Where("member_id = ?", memberId).Find(&addresses); ret.Error != nil {
    return
}
if len(addresses) > 0 {
    defineAddressIndex := 0
    for i, address := range addresses {
        if address.IsDefault == 1 {
            defineAddressIndex = i
            break
        }
    }
    result.Address = addresses[defineAddressIndex]
}

代码

package utils

import (
    "crypto/rand"
    "encoding/hex"
    "fmt"
)

func New() string {
    uuid, _ := GenerateUUID()
    return uuid
}

// GenerateRandomBytes is used to generate random bytes of given size.
func GenerateRandomBytes(size int) ([]byte, error) {
    buf := make([]byte, size)
    if _, err := rand.Read(buf); err != nil {
        return nil, fmt.Errorf("failed to read random bytes: %v", err)
    }
    return buf, nil
}

const uuidLen = 16

// GenerateUUID is used to generate a random UUID
func GenerateUUID() (string, error) {
    buf, err := GenerateRandomBytes(uuidLen)
    if err != nil {
        return "", err
    }
    return FormatUUID(buf)
}

func FormatUUID(buf []byte) (string, error) {
    if buflen := len(buf); buflen != uuidLen {
        return "", fmt.Errorf("wrong length byte slice (%d)", buflen)
    }

    return fmt.Sprintf("%x-%x-%x-%x-%x",
        buf[0:4],
        buf[4:6],
        buf[6:8],
        buf[8:10],
        buf[10:16]), nil
}

func ParseUUID(uuid string) ([]byte, error) {
    if len(uuid) != 2*uuidLen+4 {
        return nil, fmt.Errorf("uuid string is wrong length")
    }

    if uuid[8] != '-' ||
        uuid[13] != '-' ||
        uuid[18] != '-' ||
        uuid[23] != '-' {
        return nil, fmt.Errorf("uuid is improperly formatted")
    }

    hexStr := uuid[0:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36]

    ret, err := hex.DecodeString(hexStr)
    if err != nil {
        return nil, err
    }
    if len(ret) != uuidLen {
        return nil, fmt.Errorf("decoded hex is the wrong length")
    }

    return ret, nil
}

使用

uud := utils.New()
fmt.Println(uud)
//9a317a2c-b5d1-ae15-7d76-27f2b48d539a

批量替换mysql一个表中某个字段的值里面的部分字符串,使用mysql replace函数:

UPDATE prezzie_category SET image = REPLACE (image, 'http://localhost:8727','https://a.liziyu.com') where id > 0;

注意,操作之前请先备份表:

CREATE TABLE prezzie_category_bak AS SELECT * FROM prezzie_category;

Nginx反代

server
{
    listen 80;
    # 您的域名
    server_name cms.demo.mallray.com;
    # 索引文档,建议将 index.html 放在第一个
    index index.html

    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md|package.json|package-lock.json|\.env) {
        return 404;
    }


    # HTTP反向代理相关配置开始 >>>
    location / {
        # 端口为3000,自定义后请注意修改
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_connect_timeout 30s;
        proxy_read_timeout 86400s;
        proxy_send_timeout 30s;
        proxy_redirect off;
    }
    # HTTP反向代理相关配置结束 <<<

    # 有可能会存在的默认规则-【请删除它们】,否则很多资源会404 - START
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log /dev/null;
        access_log /dev/null;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log /dev/null;
        access_log /dev/null;
    }
    # 有可能会存在的默认规则-【请删除它们】,否则很多资源会404 - END
}

使用面板

  1. 进入面板,打开网站管理,切换到 Node 项目,并添加 Node 项目
  2. 项目目录选择 web-nuxt 根目录
  3. 启动选项请选择 start
  4. 真实端口填写 3000
  5. 填写正确的绑定域名,宝塔将自动配置好代理
  6. 项目添加成功后,即可使用域名访问站点,并可以方便的配置 SSL 证书等

------------ js --------------

<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script>

<script>
  var hash = CryptoJS.HmacSHA256("Message", "secret");
  var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
  document.write(hashInBase64);
</script>

------------- php ----------------

$s = hash_hmac('sha256', 'Message', 'secret', true);
echo base64_encode($s);

------------ go ------------------

func 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))
}

func main() {
    fmt.Println(ComputeHmac256("Message", "secret"))
}

通过网盘分享的文件:海康相关

链接: https://pan.baidu.com/s/1HFi-LUVvfEmJsSiNkX43Bg 提取码: 48y8

const wxuuid = function () {
  var s = [];
  var hexDigits = "0123456789abcdef";
  for (var i = 0; i < 36; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  }
  s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  s[8] = s[13] = s[18] = s[23] = "-";
 
  var uuid = s.join("");
  return uuid
};

1. Vuex 状态管理

// store/index.js
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    cart: [] // 购物车数据
  },
  mutations: {
    addToCart(state, product) {
      state.cart.push(product);
    },
    removeFromCart(state, productId) {
      state.cart = state.cart.filter(item => item.id !== productId);
    },
    clearCart(state) {
      state.cart = [];
    }
  },
  getters: {
    cartItems: state => state.cart,
    cartTotal: state => state.cart.reduce((total, item) => total + item.price * item.quantity, 0),
  }
});

2. 本地存储(localStorage / uni.setStorage)

// 添加商品到购物车
function addToCart(product) {
  let cart = uni.getStorageSync('cart') || [];
  cart.push(product);
  uni.setStorageSync('cart', cart);
}

// 获取购物车数据
function getCart() {
  return uni.getStorageSync('cart') || [];
}

// 清空购物车
function clearCart() {
  uni.removeStorageSync('cart');
}

3. 在页面中使用 cartItems

<template>
  <view>
    <text>购物车商品列表:</text>
    <view v-for="item in cartItems" :key="item.id">
      <text>{{ item.name }} - {{ item.price }} (数量: {{ item.quantity }})</text>
    </view>
    <text>总价: {{ cartTotal }}</text>
  </view>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  computed: {
    ...mapGetters(['cartItems', 'cartTotal']), // 映射 Vuex getters
  },
  methods: {
    // 其他方法
  },
  mounted() {
    // 这里可以进行其他初始化操作
  }
};
</script>

<style scoped>
/* 添加你的样式 */
</style>

小结:mapGetters这是 Vuex 提供的一个辅助函数,可以让你在组件中方便地映射 Vuexgetters 到计算属性。通过这种方式,你可以直接使用 cartItemscartTotal 作为组件的计算属性。