自己曬點兒鹽用

2021-09-22 13:40:50 字數 1796 閱讀 3487

[本文出自天外歸雲的]

自用加鹽**如下:

#

coding:utf-8

import

uuid

from functools import

reduce

defsalt(num):

if num<33333:

num = 3*(num+3)

num =salt(num)

return

numdef

encrypt(_str,password):

keys =

for char in

_str:

ifchar.isalpha():

key = ord(char)-96

else

: key =salt(ord(char))

return

password.join(keys)

defdec_mac(get_mac_address):

def password =str(password)

return str(reduce(lambda x, y: x*y,[int(one)*3 for one in encrypt(password,password).join(encrypt(get_mac_address(),password)) if int(one)!=0])).strip("0"

)

return

@dec_mac

defget_mac_address():

mac=uuid.uuid(int = uuid.getnode()).hex[-12:]

ret = "

:".join([mac[e:e+2] for e in range(0,11,2)])

return

ret.lower()

if__name__ == '

__main__':

key = "

kdfhb234kus3

"salt_mac = get_mac_address(encrypt(key,"3"

)) with open(

"cipher

","w

") as cipher:

cipher.write(salt_mac)

造鹽函式,將鹽輸出到本地cipher檔案。

查鹽函式,讀取cipher檔案中的鹽並校驗,如果和造鹽函式產出的鹽不一樣,則返回false:

def

check_salt():

key1 = "

dkfjasdlkfj

"key2 = "5"

salt_mac =get_mac_address(encrypt(key1,key2))

root_path = os.path.dirname(os.path.dirname(__file__

)) cipher_path = os.path.join(root_path,"

cipher")

with open(cipher_path,"r

") as cipher:

content =cipher.read()

if content !=salt_mac:

return false

關鍵:加鹽器中的key和查鹽器中的key要對上才能返回true,所以即使知道加鹽的邏輯不知道查鹽函式中的key也是不行的。所以要對查鹽函式的**想通過轉編譯、複雜邏輯等方法進行保護。如果逆向成本高於正向成本,保護基本可以認為是有效的。

自己用的日曆控制項

var striframe with webcalendar.iframe function webcalendar 初始化日曆的設定 var webcalendar new webcalendar function calendar 主調函式 o.display webcalendar.ifram...

FlexGrid自己用的經驗

flexgrid是乙個很好的jquery外掛程式。下面建立乙個flexgrid document ready function buttons usepager true,title 查詢結果 userp true,rp 20,singleselect true,僅允許選擇單行 width 500,...

自己用的vue總結

vue是一款漸進式前端框架,由底向上增量開發,vue.js 自身不是乙個全能框架 它只聚焦於檢視層。因此它非常容易學習,非常容易與其它庫或已有專案整合。另一方面,在與相關工具和支援庫一起使用時 vue.js 也能完美地驅動複雜的單頁應用。封裝好的應用程式,它只是js檔案的封裝。文字渲染 v text...