Compare commits

...

2 Commits

Author SHA1 Message Date
vernuser fb840f7d5e 加了ui
8 months ago
vernuser b6a3c192d3 注释都加了,看不懂拖出去突突了
8 months ago

@ -4,7 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="b490c3d2-83ec-4ee0-b2e3-44d7951d4337" name="更改" comment="加了ui" />
<list default="true" id="b490c3d2-83ec-4ee0-b2e3-44d7951d4337" name="更改" comment="已成功实现在虚拟机和物理机之间运行">
<change afterPath="$PROJECT_DIR$/ui.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/private.pem" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/public.pem" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/receiver_private.pem" beforeDir="false" afterPath="$PROJECT_DIR$/receiver_private.pem" afterDir="false" />
<change beforePath="$PROJECT_DIR$/receiver_public.pem" beforeDir="false" afterPath="$PROJECT_DIR$/receiver_public.pem" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sender_private.pem" beforeDir="false" afterPath="$PROJECT_DIR$/sender_private.pem" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sender_public.pem" beforeDir="false" afterPath="$PROJECT_DIR$/sender_public.pem" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -30,7 +39,6 @@
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="WARN_ABOUT_CRLF" value="false" />
</component>
<component name="GitHubPullRequestSearchHistory">{
&quot;history&quot;: [
@ -59,30 +67,30 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Python.client.executor&quot;: &quot;Run&quot;,
&quot;Python.encryption_utils.executor&quot;: &quot;Run&quot;,
&quot;Python.file_transfer.executor&quot;: &quot;Run&quot;,
&quot;Python.generate_key.executor&quot;: &quot;Run&quot;,
&quot;Python.generate_keys.executor&quot;: &quot;Run&quot;,
&quot;Python.receiver.executor&quot;: &quot;Run&quot;,
&quot;Python.sender.executor&quot;: &quot;Run&quot;,
&quot;Python.server.executor&quot;: &quot;Run&quot;,
&quot;Python.ui.executor&quot;: &quot;Run&quot;,
&quot;Python.utils.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;annn&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/Asus/Desktop/烽台校园实习/交接资料/实验室仿真台攻击脚本/实验室仿真台攻击脚本/仿真台攻击脚本11.22&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Python.client.executor": "Run",
"Python.encryption_utils.executor": "Run",
"Python.file_transfer.executor": "Run",
"Python.generate_key.executor": "Run",
"Python.generate_keys.executor": "Run",
"Python.receiver.executor": "Run",
"Python.sender.executor": "Run",
"Python.server.executor": "Run",
"Python.ui.executor": "Run",
"Python.utils.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "annn",
"last_opened_file_path": "C:/Users/Asus/Desktop/烽台校园实习/交接资料/实验室仿真台攻击脚本/实验室仿真台攻击脚本/仿真台攻击脚本11.22",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}</component>
}]]></component>
<component name="RunManager" selected="Python.ui">
<configuration name="generate_key" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="应用密码学课设" />
@ -234,7 +242,7 @@
<workItem from="1734488993135" duration="581000" />
<workItem from="1734607228597" duration="4000" />
<workItem from="1734770663055" duration="28000" />
<workItem from="1734779266249" duration="2556000" />
<workItem from="1734779266249" duration="2176000" />
</task>
<task id="LOCAL-00001" summary="加了互传">
<option name="closed" value="true" />
@ -284,15 +292,7 @@
<option name="project" value="LOCAL" />
<updated>1734489392435</updated>
</task>
<task id="LOCAL-00007" summary="加了ui">
<option name="closed" value="true" />
<created>1734782367798</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1734782367798</updated>
</task>
<option name="localTasksCounter" value="8" />
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -326,15 +326,14 @@
<MESSAGE value="加了中文" />
<MESSAGE value="签名错误?" />
<MESSAGE value="已成功实现在虚拟机和物理机之间运行" />
<MESSAGE value="加了ui" />
<option name="LAST_COMMIT_MESSAGE" value="加了ui" />
<option name="LAST_COMMIT_MESSAGE" value="已成功实现在虚拟机和物理机之间运行" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/$receiver.coverage" NAME="receiver 覆盖结果" MODIFIED="1734342809902" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$file_transfer.coverage" NAME="file_transfer 覆盖结果" MODIFIED="1733810226775" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$server.coverage" NAME="server 覆盖结果" MODIFIED="1734342831970" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$utils.coverage" NAME="utils 覆盖结果" MODIFIED="1734342818616" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$ui.coverage" NAME="ui 覆盖结果" MODIFIED="1734782287253" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$ui.coverage" NAME="ui 覆盖结果" MODIFIED="1734781859043" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$generate_key.coverage" NAME="generate_key 覆盖结果" MODIFIED="1734781683799" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$generate_keys.coverage" NAME="generate_keys 覆盖结果" MODIFIED="1733809016631" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/$encryption_utils.coverage" NAME="encryption_utils 覆盖结果" MODIFIED="1734342806348" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />

@ -6,28 +6,35 @@ from Crypto.Hash import SHA256
class AsymmetricEncryption:
def __init__(self):
# 生成2048位的RSA密钥对
self.key_pair = RSA.generate(2048)
def get_public_key(self):
# 返回公钥
return self.key_pair.publickey()
def get_private_key(self):
# 返回私钥
return self.key_pair
def encrypt_with_public_key(self, data, public_key):
# 使用公钥加密数据
cipher_rsa = PKCS1_OAEP.new(public_key)
return cipher_rsa.encrypt(data)
def decrypt_with_private_key(self, encrypted_data):
# 使用私钥解密数据
cipher_rsa = PKCS1_OAEP.new(self.key_pair)
return cipher_rsa.decrypt(encrypted_data)
def sign_data(self, data):
# 对数据进行SHA256哈希然后使用私钥生成签名
h = SHA256.new(data)
signature = pkcs1_15.new(self.key_pair).sign(h)
return signature
def verify_signature(self, data, signature, public_key):
# 对数据进行SHA256哈希然后使用公钥验证签名
h = SHA256.new(data)
try:
pkcs1_15.new(public_key).verify(h, signature)
@ -37,11 +44,13 @@ class AsymmetricEncryption:
class SymmetricEncryption:
def encrypt(self, data, key):
# 使用AES-GCM模式加密数据
cipher_aes = AES.new(key, AES.MODE_GCM)
nonce = cipher_aes.nonce
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
return nonce, ciphertext, tag
def decrypt(self, nonce, ciphertext, tag, key):
# 使用AES-GCM模式解密数据并验证
cipher_aes = AES.new(key, AES.MODE_GCM, nonce=nonce)
return cipher_aes.decrypt_and_verify(ciphertext, tag)
Loading…
Cancel
Save