AES.MODE_EAX)# 加密数据plaintext=b'This is a secret message.'ciphertext,tag=cipher.encrypt_and...
# be encoded to byte string before encryption encMessage = fernet.encrypt(message.encode()) print("original string: ", message) print("encrypted string: ", encMessage) # decrypt the encrypted string with the # Fernet instance of the key, # that was used for encrypting the string # encoded...
defencrypt_string(string):encrypted_string=""forcharinstring:ifchar.isupper():encrypted_char=chr((ord(char)-ord('A')+5)%26+ord('A'))encrypted_string+=encrypted_charelse:encrypted_string+=charreturnencrypted_string# 示例string="HELLO WORLD"encrypted_string=encrypt_string(string)print(encrypted_s...
s1 = base64.encodestring('hello world') s2 = base64.decodestring(s1) print s1,s2 # aGVsbG8gd29ybGQ=\n # hello world Note:这是最简单的方法了,但是不够保险,因为如果别人拿到你的密文,也可以自己解密来得到明文 2. 第二种方法是使用win32com.client import win32com.client def encrypt(key,con...
s2=base64.decodestring(s1) prints1,s2 #aGVsbG8gd29ybGQ=\n #hello world Note:这是最简单的方法了,但是不够保险,因为如果别人拿到你的密文,也可以自己解密来得到明文 2. 第二种方法是使用win32com.client importwin32com.client defencrypt(key,content):#key:密钥,content:明文 ...
def encrypt(key, s): b = bytearray(str(s).encode(gbk)) n = len(b) # 求出 b 的字节数 c = bytearray(n*2) j = 0 for i in range(0, n): b1 = b[i] b2 = b1 ^ key # b1 = b2^ key c1 = b2 % 16 c2 = b2 // 16 # b2 = c2*16 + c1 ...
you can import it directly from the file # #from stringencrypt.stringencrypt import StringEncrypt # # create StringEncrypt class instance (we are using our activation code) # myStringEncrypt = StringEncrypt("ABCD-ABCD-ABCD-ABCD") # # encrypt a string using all the default options # result ...
b"string" 这是我的 AES 代码: # Encryptionencryption_suite= AES.new(b'1234567812345678', AES.MODE_OCB)cipher_text= encryption_suite.encrypt(b"A really secret message. Not for prying eyes.")# Decryptiondecryption_suite= AES.new(b'1234567812345678', AES.MODE_OCB)plaintext= decryption_suite.decr...
s1 = encrypt(key, 'hello world') s2 = decrypt(key, s1) print s1,'\n',s2 # HGKGDGDGAGPCIHAGNHDGLG # hello world 注: 这是网上抄来的一个简单的例子,大家可以自定义自己算法进行加密解密;还有许许多多复杂的加密算法,大家可以自行查阅密码学的相关算法。
"7b07a672" def aes_encrypt(data_string): aes = DES.new( key=KEY.encode('utf-8'), mode=DES.MODE_CBC, iv=IV.encode('utf-8') ) raw = pad(data_string.encode('utf-8'), 8) return aes.encrypt(raw) data = aes_encrypt("小逗逗") print(data) print([ i for i in ...