c 讀取硬體資訊並進行加密繫結

2021-09-03 01:53:58 字數 1727 閱讀 2288

讀取硬體資訊(此例中讀取cpu和磁碟資訊)

加密解密

注意:1.磁碟資訊包括插入的行動硬碟或u盤,如果將此資訊也繫結,那麼插入外部儲存裝置比如u盤的時候會誤導加密程式。2.加密和解密採用通用的加密演算法,需要新增使用者自己的字段參與運算以增加加密可靠性,此例程中採用helloword欄位參與加密運算,當然解密必須要採用與加密完全相同的字段。

所需命名空間:using system.management;

**段:

private

string

getsysteminfo()

string cpuinfo =

string

.empty;

managementclass mc =

newmanagementclass

("win32_processor");

managementobjectcollection moc = mc.

getinstances()

;foreach

(managementobject mo in moc)

return cpuinfo + dskinfo;

}

命名空間:using system.security.cryptography;

**示例:

private

string

encrypt

(string cleartext));

encryptor.key = pdb.

getbytes(32

);encryptor.iv = pdb.

getbytes(16

);using

(memorystream ms =

newmemorystream()

) cleartext = convert.

tobase64string

(ms.

toarray()

);}}

return cleartext;

}

命名空間:using system.security.cryptography;

示例**:

private

string

decrypt

(string ciphertext)

catch

(exception e)

byte

cipherbytes = convert.

frombase64string

(ciphertext)

;using

(aes encryptor = aes.

create()

)); encryptor.key = pdb.

getbytes(32

);encryptor.iv = pdb.

getbytes(16

);using

(memorystream ms =

newmemorystream()

) ciphertext = encoding.unicode.

getstring

(ms.

toarray()

);}}

return ciphertext;

}

從C 中讀取硬體以及系統資訊

using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.text using system.window...

Python讀取多個txt檔案並進行儲存

記憶力不好的孩紙得勤做筆記!最近開始接觸python,現在分享下寫的第二個 好了,多的不說,直接上 作業系統為windons.coding utf 8 import matplotlib.pyplot as plt import numpy as np 距離temp 3.0 定義字典相當於c 中巨集...

python 讀取excel並進行檔案複製

coding utf 8 import xlrd import shutil import os def read excel 開啟檔案 workbook xlrd.open workbook r c users desktop xls 獲取所有sheet print workbook.sheet ...