import numpy as np
import datetime
def my_encode_mat(strings):
date = datetime.datetime.today()
w = np.array(date.__repr__().replace(' ','').split(',')[1:-1]).astype(int).max()
randomkey = eval('np.random.randint(0,10)+w,'*len(strings))
matmsm = np.array([[ord(s),i,(len(strings)%randomkey[0])] for s,i in zip(strings,randomkey)])
m,n = matmsm.shape
theta = np.ones((n))
stringsarray = np.log(np.dot(matmsm,theta))
key = np.c_[stringsarray,randomkey]
cipher = ''.join([''.join(list(map(lambda x : hex(ord(x))[2:] , '{}{}{}{}'.format(i.__repr__(),'-',format(date).split(' ')[0],'-'))))for i in stringsarray])
keyList = []
for i in key:
keyList+=list(i)
return keyList,cipher
def my_decode_mat(keylist,cipher):
matkey = np.array([[keyList[i],keyList[i+1]] for i in range(len(keyList)) if i % 2 != 1])
stringsarray ,randomkey = matkey[:,0],matkey[:,1]
src = "".join([chr(int('{}{}'.format('0x',cipher[i:i+2]),16)) for i in range(0,len(cipher),2)]).split('-')
y = np.array([src[i] for i in range(len(src)) if i % 4 == 0][:-1]).astype(float)
encodedate = ''.join(["{}{}".format('-',j) for j in [src[i] for i in range(len(src)) if i % 4 != 0][:3]])[1:]
n3 = [len(randomkey)%randomkey[0]]*len(randomkey)
n2 = randomkey
return ''.join([chr(int(round(i))) for i in np.exp(y)-n2-n3]),encodedate
key,cipher = my_encode_mat('天使之国')
decode ,encodedate = my_decode_mat(key,cipher)
decode
cipher
encodedate
私人新版加密算法初版
最新推荐文章于 2024-04-28 08:42:25 发布