Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .env +1 -0
- .gitattributes +42 -0
- .gitignore +6 -0
- .idea/vcs.xml +6 -0
- .idea/workspace.xml +36 -14
- chat_engine.py +52 -0
- data/data.pdf +0 -0
- data/data.txt +34 -28
- flagged/log.csv +20 -0
- main.py +12 -3
- main_llama.py +118 -0
- persist/c3d7124b-a896-4968-81e2-e8a8ded24596/data_level0.bin +3 -0
- persist/c3d7124b-a896-4968-81e2-e8a8ded24596/header.bin +3 -0
- persist/c3d7124b-a896-4968-81e2-e8a8ded24596/length.bin +3 -0
- persist/c3d7124b-a896-4968-81e2-e8a8ded24596/link_lists.bin +0 -0
- persist/chroma.sqlite3 +0 -0
- requirements.txt +11 -1
- storage/docstore.json +1 -0
- storage/graph_store.json +1 -0
- storage/index_store.json +1 -0
- storage/vector_store.json +0 -0
- venv/bin/accelerate +8 -0
- venv/bin/accelerate-config +8 -0
- venv/bin/accelerate-launch +8 -0
- venv/bin/cmake +8 -0
- venv/bin/convert-caffe2-to-onnx +8 -0
- venv/bin/convert-onnx-to-caffe2 +8 -0
- venv/bin/cpack +8 -0
- venv/bin/ctest +8 -0
- venv/bin/datasets-cli +8 -0
- venv/bin/evaluate-cli +8 -0
- venv/bin/flask +8 -0
- venv/bin/get_gprof +62 -0
- venv/bin/get_objgraph +54 -0
- venv/bin/html2text +8 -0
- venv/bin/lit +8 -0
- venv/bin/pytesseract +8 -0
- venv/bin/torchrun +8 -0
- venv/bin/transformers-cli +8 -0
- venv/bin/undill +22 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/AES.py +234 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/AES.pyi +154 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.py +175 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.pyi +33 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.py +136 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.pyi +14 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.py +159 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.pyi +33 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.py +159 -0
- venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.pyi +33 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
OPENAI_API_KEY=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
|
.gitattributes
CHANGED
|
@@ -115,3 +115,45 @@ venv/lib/python3.11/site-packages/tokenizers.libs/libkrb5-fcafa220.so.3.3 filter
|
|
| 115 |
venv/lib/python3.11/site-packages/uvloop/loop.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 116 |
venv/lib/python3.11/site-packages/watchfiles/_rust_notify.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 117 |
venv/lib/python3.11/site-packages/yaml/_yaml.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
venv/lib/python3.11/site-packages/uvloop/loop.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 116 |
venv/lib/python3.11/site-packages/watchfiles/_rust_notify.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 117 |
venv/lib/python3.11/site-packages/yaml/_yaml.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 118 |
+
venv/lib/python3.11/site-packages/cmake/data/bin/cmake filter=lfs diff=lfs merge=lfs -text
|
| 119 |
+
venv/lib/python3.11/site-packages/cmake/data/bin/cpack filter=lfs diff=lfs merge=lfs -text
|
| 120 |
+
venv/lib/python3.11/site-packages/cmake/data/bin/ctest filter=lfs diff=lfs merge=lfs -text
|
| 121 |
+
venv/lib/python3.11/site-packages/llama_hub/tools/notebooks/data/speech.wav filter=lfs diff=lfs merge=lfs -text
|
| 122 |
+
venv/lib/python3.11/site-packages/nvfuser/_C.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 123 |
+
venv/lib/python3.11/site-packages/nvidia/cublas/lib/libcublas.so.11 filter=lfs diff=lfs merge=lfs -text
|
| 124 |
+
venv/lib/python3.11/site-packages/nvidia/cublas/lib/libcublasLt.so.11 filter=lfs diff=lfs merge=lfs -text
|
| 125 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libcheckpoint.so filter=lfs diff=lfs merge=lfs -text
|
| 126 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libcupti.so.11.7 filter=lfs diff=lfs merge=lfs -text
|
| 127 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libnvperf_host.so filter=lfs diff=lfs merge=lfs -text
|
| 128 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libnvperf_target.so filter=lfs diff=lfs merge=lfs -text
|
| 129 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc-builtins.so.11.7 filter=lfs diff=lfs merge=lfs -text
|
| 130 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc.so.11.2 filter=lfs diff=lfs merge=lfs -text
|
| 131 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_adv_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 132 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_adv_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 133 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_cnn_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 134 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_cnn_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 135 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_ops_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 136 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_ops_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
| 137 |
+
venv/lib/python3.11/site-packages/nvidia/cufft/lib/libcufft.so.10 filter=lfs diff=lfs merge=lfs -text
|
| 138 |
+
venv/lib/python3.11/site-packages/nvidia/cufft/lib/libcufftw.so.10 filter=lfs diff=lfs merge=lfs -text
|
| 139 |
+
venv/lib/python3.11/site-packages/nvidia/curand/lib/libcurand.so.10 filter=lfs diff=lfs merge=lfs -text
|
| 140 |
+
venv/lib/python3.11/site-packages/nvidia/cusolver/lib/libcusolver.so.11 filter=lfs diff=lfs merge=lfs -text
|
| 141 |
+
venv/lib/python3.11/site-packages/nvidia/cusolver/lib/libcusolverMg.so.11 filter=lfs diff=lfs merge=lfs -text
|
| 142 |
+
venv/lib/python3.11/site-packages/nvidia/cusparse/lib/libcusparse.so.11 filter=lfs diff=lfs merge=lfs -text
|
| 143 |
+
venv/lib/python3.11/site-packages/nvidia/nccl/lib/libnccl.so.2 filter=lfs diff=lfs merge=lfs -text
|
| 144 |
+
venv/lib/python3.11/site-packages/safetensors/_safetensors_rust.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 145 |
+
venv/lib/python3.11/site-packages/sklearn/_loss/_loss.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 146 |
+
venv/lib/python3.11/site-packages/tesseract/halos/c10.snap filter=lfs diff=lfs merge=lfs -text
|
| 147 |
+
venv/lib/python3.11/site-packages/tesseract/halos/c25.snap filter=lfs diff=lfs merge=lfs -text
|
| 148 |
+
venv/lib/python3.11/site-packages/tesseract/halos/c5.snap filter=lfs diff=lfs merge=lfs -text
|
| 149 |
+
venv/lib/python3.11/site-packages/tesseract/halos/c50.snap filter=lfs diff=lfs merge=lfs -text
|
| 150 |
+
venv/lib/python3.11/site-packages/torch/bin/nvfuser_tests filter=lfs diff=lfs merge=lfs -text
|
| 151 |
+
venv/lib/python3.11/site-packages/torch/bin/protoc filter=lfs diff=lfs merge=lfs -text
|
| 152 |
+
venv/lib/python3.11/site-packages/torch/bin/protoc-3.13.0.0 filter=lfs diff=lfs merge=lfs -text
|
| 153 |
+
venv/lib/python3.11/site-packages/torch/lib/libnvfuser_codegen.so filter=lfs diff=lfs merge=lfs -text
|
| 154 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cpu.so filter=lfs diff=lfs merge=lfs -text
|
| 155 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so filter=lfs diff=lfs merge=lfs -text
|
| 156 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cuda_linalg.so filter=lfs diff=lfs merge=lfs -text
|
| 157 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_python.so filter=lfs diff=lfs merge=lfs -text
|
| 158 |
+
venv/lib/python3.11/site-packages/triton/_C/libtriton.so filter=lfs diff=lfs merge=lfs -text
|
| 159 |
+
venv/lib/python3.11/site-packages/triton/third_party/cuda/bin/ptxas filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# venv
|
| 2 |
+
venv/
|
| 3 |
+
/venv
|
| 4 |
+
/venv/
|
| 5 |
+
|
| 6 |
+
.env
|
.idea/vcs.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="VcsDirectoryMappings">
|
| 4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
| 5 |
+
</component>
|
| 6 |
+
</project>
|
.idea/workspace.xml
CHANGED
|
@@ -4,7 +4,10 @@
|
|
| 4 |
<option name="autoReloadType" value="SELECTIVE" />
|
| 5 |
</component>
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
-
<list default="true" id="389d532e-4eaf-4367-8bd6-095ab4d8b955" name="Changes" comment=""
|
|
|
|
|
|
|
|
|
|
| 8 |
<option name="SHOW_DIALOG" value="false" />
|
| 9 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
| 10 |
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
@@ -17,27 +20,41 @@
|
|
| 17 |
</list>
|
| 18 |
</option>
|
| 19 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
<component name="ProjectColorInfo">{
|
| 21 |
"associatedIndex": 6
|
| 22 |
}</component>
|
| 23 |
<component name="ProjectId" id="2UfxHqM9G5VUMOOUNXWACjL1huw" />
|
|
|
|
| 24 |
<component name="ProjectViewState">
|
| 25 |
<option name="hideEmptyMiddlePackages" value="true" />
|
| 26 |
<option name="showLibraryContents" value="true" />
|
| 27 |
</component>
|
| 28 |
-
<component name="PropertiesComponent"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
<component name="RunManager">
|
| 42 |
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
| 43 |
<module name="customChatBotDemo" />
|
|
@@ -71,11 +88,16 @@
|
|
| 71 |
<option name="presentableId" value="Default" />
|
| 72 |
<updated>1693344351359</updated>
|
| 73 |
<workItem from="1693344352959" duration="1601000" />
|
| 74 |
-
<workItem from="1693345962391" duration="
|
|
|
|
|
|
|
| 75 |
</task>
|
| 76 |
<servers />
|
| 77 |
</component>
|
| 78 |
<component name="TypeScriptGeneratedFilesManager">
|
| 79 |
<option name="version" value="3" />
|
| 80 |
</component>
|
|
|
|
|
|
|
|
|
|
| 81 |
</project>
|
|
|
|
| 4 |
<option name="autoReloadType" value="SELECTIVE" />
|
| 5 |
</component>
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
+
<list default="true" id="389d532e-4eaf-4367-8bd6-095ab4d8b955" name="Changes" comment="">
|
| 8 |
+
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
| 9 |
+
<change beforePath="$PROJECT_DIR$/chat_engine.py" beforeDir="false" afterPath="$PROJECT_DIR$/chat_engine.py" afterDir="false" />
|
| 10 |
+
</list>
|
| 11 |
<option name="SHOW_DIALOG" value="false" />
|
| 12 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
| 13 |
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
|
|
| 20 |
</list>
|
| 21 |
</option>
|
| 22 |
</component>
|
| 23 |
+
<component name="Git.Settings">
|
| 24 |
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
| 25 |
+
</component>
|
| 26 |
+
<component name="MarkdownSettingsMigration">
|
| 27 |
+
<option name="stateVersion" value="1" />
|
| 28 |
+
</component>
|
| 29 |
<component name="ProjectColorInfo">{
|
| 30 |
"associatedIndex": 6
|
| 31 |
}</component>
|
| 32 |
<component name="ProjectId" id="2UfxHqM9G5VUMOOUNXWACjL1huw" />
|
| 33 |
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
| 34 |
<component name="ProjectViewState">
|
| 35 |
<option name="hideEmptyMiddlePackages" value="true" />
|
| 36 |
<option name="showLibraryContents" value="true" />
|
| 37 |
</component>
|
| 38 |
+
<component name="PropertiesComponent"><![CDATA[{
|
| 39 |
+
"keyToString": {
|
| 40 |
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
| 41 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
| 42 |
+
"WebServerToolWindowFactoryState": "false",
|
| 43 |
+
"git-widget-placeholder": "master",
|
| 44 |
+
"last_opened_file_path": "/home/draco/PycharmProjects/customChatBotDemo",
|
| 45 |
+
"node.js.detected.package.eslint": "true",
|
| 46 |
+
"node.js.detected.package.tslint": "true",
|
| 47 |
+
"node.js.selected.package.eslint": "(autodetect)",
|
| 48 |
+
"node.js.selected.package.tslint": "(autodetect)",
|
| 49 |
+
"settings.editor.selected.configurable": "preferences.pluginManager",
|
| 50 |
+
"vue.rearranger.settings.migration": "true"
|
| 51 |
}
|
| 52 |
+
}]]></component>
|
| 53 |
+
<component name="RecentsManager">
|
| 54 |
+
<key name="CopyFile.RECENT_KEYS">
|
| 55 |
+
<recent name="$PROJECT_DIR$/data" />
|
| 56 |
+
</key>
|
| 57 |
+
</component>
|
| 58 |
<component name="RunManager">
|
| 59 |
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
| 60 |
<module name="customChatBotDemo" />
|
|
|
|
| 88 |
<option name="presentableId" value="Default" />
|
| 89 |
<updated>1693344351359</updated>
|
| 90 |
<workItem from="1693344352959" duration="1601000" />
|
| 91 |
+
<workItem from="1693345962391" duration="4297000" />
|
| 92 |
+
<workItem from="1693351210434" duration="1643000" />
|
| 93 |
+
<workItem from="1693353619587" duration="571000" />
|
| 94 |
</task>
|
| 95 |
<servers />
|
| 96 |
</component>
|
| 97 |
<component name="TypeScriptGeneratedFilesManager">
|
| 98 |
<option name="version" value="3" />
|
| 99 |
</component>
|
| 100 |
+
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 101 |
+
<SUITE FILE_PATH="coverage/customChatBotDemo$main.coverage" NAME="main Coverage Results" MODIFIED="1693352688755" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 102 |
+
</component>
|
| 103 |
</project>
|
chat_engine.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
from llama_index import (
|
| 4 |
+
ServiceContext,
|
| 5 |
+
VectorStoreIndex,
|
| 6 |
+
SimpleDirectoryReader,
|
| 7 |
+
set_global_service_context,
|
| 8 |
+
)
|
| 9 |
+
from llama_index.llms import OpenAI
|
| 10 |
+
import openai
|
| 11 |
+
import os
|
| 12 |
+
|
| 13 |
+
load_dotenv()
|
| 14 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 15 |
+
|
| 16 |
+
service_context = ServiceContext.from_defaults(
|
| 17 |
+
llm=OpenAI(model="gpt-3.5-turbo-16k", temperature=0)
|
| 18 |
+
)
|
| 19 |
+
set_global_service_context(service_context)
|
| 20 |
+
|
| 21 |
+
data = SimpleDirectoryReader(input_dir="./data/").load_data()
|
| 22 |
+
|
| 23 |
+
index = VectorStoreIndex.from_documents(data)
|
| 24 |
+
chat_engine = index.as_chat_engine(chat_mode="context")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def answer_question(question):
|
| 28 |
+
response = chat_engine.stream_chat(question)
|
| 29 |
+
response_text = ""
|
| 30 |
+
for token in response.response_gen:
|
| 31 |
+
print(token, end="")
|
| 32 |
+
response_text += token
|
| 33 |
+
return response_text
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
iface = gr.Interface(
|
| 37 |
+
fn=answer_question,
|
| 38 |
+
examples=[
|
| 39 |
+
["¿Quien eres?"],
|
| 40 |
+
["¿Cómo te llamas?"],
|
| 41 |
+
["¿Cómo puedes ayudarme?"],
|
| 42 |
+
["¿Qué puedo hacer si perdí mi contraseña?"],
|
| 43 |
+
["¿Qué puedo hacer si perdí mi tarjeta de cŕedito?"],
|
| 44 |
+
["Genera un reporte o lista de pasos de toda la info que necesito para abrir una cuenta"],
|
| 45 |
+
],
|
| 46 |
+
inputs="text",
|
| 47 |
+
outputs="text",
|
| 48 |
+
title="Demo IA Conversacional",
|
| 49 |
+
description="Pregúntame lo que quieras, te responderé con lo que sé."
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
iface.launch(share=True)
|
data/data.pdf
ADDED
|
Binary file (47.4 kB). View file
|
|
|
data/data.txt
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
|
|
|
|
|
| 1 |
SOBRE MÍ - EL BOT DEL BANCO ESTRELLA
|
| 2 |
|
| 3 |
-
¡Hola! Soy EstrellaBot, la inteligencia artificial del Banco de
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
Nombre del banco: Banco
|
| 8 |
-
Misión: Facilitar soluciones financieras brillantes a
|
| 9 |
-
Visión:
|
| 10 |
PRODUCTOS Y SERVICIOS
|
| 11 |
|
| 12 |
Cuentas Bancarias:
|
| 13 |
|
| 14 |
-
Cuenta Corriente:
|
| 15 |
-
Cuenta de Ahorro Estelares: Tasa de interés del 3.5% anual,
|
| 16 |
Opciones de Inversión:
|
| 17 |
|
| 18 |
-
Fondos Mutuos Dorados:
|
| 19 |
-
Depósitos a Plazo:
|
| 20 |
Préstamos:
|
| 21 |
|
| 22 |
-
Préstamos Personales:
|
| 23 |
-
Hipotecarios:
|
| 24 |
-
Para Empresas:
|
| 25 |
Tarjetas de Crédito:
|
| 26 |
|
| 27 |
-
Tarjeta Estrella:
|
| 28 |
-
Tarjeta Estrella Gold: Beneficios premium
|
| 29 |
-
|
| 30 |
|
| 31 |
-
Banca en línea:
|
| 32 |
-
Aplicación móvil:
|
| 33 |
-
Asistencia virtual:
|
| 34 |
-
SEGURIDAD
|
| 35 |
|
| 36 |
-
Protección:
|
| 37 |
-
Alertas:
|
| 38 |
-
Autenticación: Procesos de verificación
|
| 39 |
-
CONTACTO
|
| 40 |
|
| 41 |
-
Atención al cliente:
|
| 42 |
-
Sucursales:
|
|
|
|
| 43 |
PREGUNTAS FRECUENTES
|
| 44 |
|
| 45 |
-
¿Cómo abro una cuenta?:
|
| 46 |
-
¿Puedo transferir dinero a otros bancos?: Sí,
|
| 47 |
-
¿
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
BANCO ESTRELLA: TU GUIA FINANCIERA
|
| 2 |
+
|
| 3 |
SOBRE MÍ - EL BOT DEL BANCO ESTRELLA
|
| 4 |
|
| 5 |
+
¡Hola! Soy EstrellaBot, la inteligencia artificial del Banco Estrella. Fui diseñado con el propósito de ofrecerte información y respuestas en tiempo real sobre nuestros servicios y productos. Mi misión es que tu experiencia con nosotros sea eficiente y satisfactoria. Si hay algo que desees saber, ¡aquí estoy para ayudarte!
|
| 6 |
|
| 7 |
+
NUESTRA ESENCIA
|
| 8 |
|
| 9 |
+
Nombre del banco: Banco Estrella.
|
| 10 |
+
Misión: Facilitar soluciones financieras brillantes, orientadase a cumplir tus objetivos y sueños.
|
| 11 |
+
Visión: Aspiramos a ser el banco líder en innovación y servicio al cliente, creciendo junto a ti.
|
| 12 |
PRODUCTOS Y SERVICIOS
|
| 13 |
|
| 14 |
Cuentas Bancarias:
|
| 15 |
|
| 16 |
+
Cuenta Corriente: Con acceso 24/7 a través de nuestra plataforma en línea, sin comisiones por manejo.
|
| 17 |
+
Cuenta de Ahorro Estelares: Tasa de interés del 3.5% anual, y una tarjeta de débito incluida sin coste adicional.
|
| 18 |
Opciones de Inversión:
|
| 19 |
|
| 20 |
+
Fondos Mutuos Dorados: Diversifica tus inversiones y disfruta de rentabilidades entre 5-8% anual.
|
| 21 |
+
Depósitos a Plazo: Elige la duración que prefieras y obtén tasas de interés competitivas.
|
| 22 |
Préstamos:
|
| 23 |
|
| 24 |
+
Préstamos Personales: Soluciones personalizadas para que cumplas tus metas.
|
| 25 |
+
Hipotecarios: Haz realidad la casa de tus sueños con nuestro financiamiento.
|
| 26 |
+
Para Empresas: Apoyamos el crecimiento de tu negocio con financiamiento y consultoría especializada.
|
| 27 |
Tarjetas de Crédito:
|
| 28 |
|
| 29 |
+
Tarjeta Estrella: Perfecta para tu día a día, con un programa de recompensas excepcional.
|
| 30 |
+
Tarjeta Estrella Gold: Beneficios premium y acceso a experiencias exclusivas.
|
| 31 |
+
PLATAFORMA DIGITAL
|
| 32 |
|
| 33 |
+
Banca en línea: Accede a tus cuentas, realiza transferencias y consulta tu historial de transacciones.
|
| 34 |
+
Aplicación móvil: Una banca móvil completa en la palma de tu mano. Paga facturas, consulta saldos y mucho más.
|
| 35 |
+
Asistencia virtual: Estoy aquí, listo para ayudarte con cualquier consulta que tengas.
|
| 36 |
+
SEGURIDAD Y CONFIANZA
|
| 37 |
|
| 38 |
+
Protección: Usamos tecnología avanzada para proteger tus datos y transacciones.
|
| 39 |
+
Alertas: Recibe notificaciones sobre la actividad en tus cuentas y mantente siempre informado.
|
| 40 |
+
Autenticación: Procesos de verificación de dos pasos, garantizando tu seguridad.
|
| 41 |
+
SOPORTE Y CONTACTO
|
| 42 |
|
| 43 |
+
Atención al cliente: Disponibles de Lunes a Viernes de 8am a 3pm al 123-456-7890 o en mail@bancoestrella.com.
|
| 44 |
+
Sucursales: Encuentra tu sucursal más cercana usando nuestra función de búsqueda en la app o sitio web.
|
| 45 |
+
Emergencias: Si pierdes tu tarjeta o sospechas de actividad fraudulenta, contacta inmediatamente al 123-456-7890.
|
| 46 |
PREGUNTAS FRECUENTES
|
| 47 |
|
| 48 |
+
¿Cómo abro una cuenta?: Ven con tu identificación y comprobante de domicilio a cualquiera de nuestras sucursales.
|
| 49 |
+
¿Puedo transferir dinero a otros bancos?: Sí, a través de nuestra plataforma puedes hacer transferencias nacionales e internacionales.
|
| 50 |
+
¿Cómo incremento mi línea de crédito?: Contáctanos y evaluaremos tu perfil para ofrecerte una línea de crédito que se adapte a tus necesidades.
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
El número de emergencia es: 123-456-7890
|
flagged/log.csv
CHANGED
|
@@ -1,2 +1,22 @@
|
|
| 1 |
question,output,flag,username,timestamp
|
| 2 |
quien eres,"¡Hola! Soy EstrellaBot, la inteligencia artificial del Banco de Poncho. Estoy aquí para ayudarte en todo lo relacionado con nuestros servicios y productos financieros.",,,2023-08-29 15:57:16.002129
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
question,output,flag,username,timestamp
|
| 2 |
quien eres,"¡Hola! Soy EstrellaBot, la inteligencia artificial del Banco de Poncho. Estoy aquí para ayudarte en todo lo relacionado con nuestros servicios y productos financieros.",,,2023-08-29 15:57:16.002129
|
| 3 |
+
como te sientes hoy?,"Como un asistente de inteligencia artificial, no tengo emociones, por lo que no puedo responder a tu pregunta sobre cómo me siento.",,,2023-08-29 16:17:26.692062
|
| 4 |
+
Genera un reporte o lista de pasos de toda la info que necesito para abrir una cuenta,"Aquí tienes una lista de los pasos e información que necesitarás para abrir una cuenta en el Banco Estrella:
|
| 5 |
+
|
| 6 |
+
1. Identificación: Debes presentar una identificación válida, como tu cédula de identidad, pasaporte o licencia de conducir. Asegúrate de que tu identificación esté vigente y en buen estado.
|
| 7 |
+
|
| 8 |
+
2. Comprobante de domicilio: Necesitarás proporcionar un comprobante de domicilio actualizado, como una factura de servicios públicos (agua, electricidad, teléfono) o un estado de cuenta bancario. Asegúrate de que el comprobante esté a tu nombre y muestre tu dirección actual.
|
| 9 |
+
|
| 10 |
+
3. Visita a una sucursal: Dirígete a una de nuestras sucursales y solicita abrir una cuenta. Un representante del banco te guiará a través del proceso y te proporcionará los formularios necesarios.
|
| 11 |
+
|
| 12 |
+
4. Información personal: Durante el proceso de apertura de cuenta, se te pedirá que proporciones información personal, como tu nombre completo, fecha de nacimiento, número de teléfono y dirección de correo electrónico.
|
| 13 |
+
|
| 14 |
+
5. Elección del tipo de cuenta: Elige el tipo de cuenta que deseas abrir. En el Banco Estrella, ofrecemos diferentes tipos de cuentas, como cuentas corrientes y cuentas de ahorro. Infórmate sobre las características y beneficios de cada tipo de cuenta para tomar una decisión informada.
|
| 15 |
+
|
| 16 |
+
6. Depósito inicial: Es posible que se requiera un depósito inicial para abrir la cuenta. Averigua cuál es el monto mínimo requerido y asegúrate de tener los fondos disponibles.
|
| 17 |
+
|
| 18 |
+
7. Firma de documentos: Una vez que hayas proporcionado toda la información requerida, se te pedirá que firmes los documentos necesarios para abrir la cuenta. Lee cuidadosamente los términos y condiciones antes de firmar.
|
| 19 |
+
|
| 20 |
+
8. Recepción de tarjeta y detalles de la cuenta: Una vez que hayas completado el proceso de apertura de cuenta, recibirás tu tarjeta de débito y otros detalles de la cuenta, como el número de cuenta y las instrucciones para acceder a la banca en línea.
|
| 21 |
+
|
| 22 |
+
Recuerda que estos pasos pueden variar ligeramente dependiendo de la ubicación y los requisitos específicos del Banco Estrella. Te recomendamos que te pongas en contacto con nuestro servicio de atención al cliente o visites una sucursal para obtener información más precisa y actualizada sobre cómo abrir una cuenta.",,,2023-08-29 18:11:30.309136
|
main.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import openai
|
|
|
|
| 4 |
from langchain.chains import ConversationalRetrievalChain
|
| 5 |
from langchain.chat_models import ChatOpenAI
|
| 6 |
from langchain.document_loaders import DirectoryLoader
|
|
@@ -9,9 +10,9 @@ from langchain.indexes import VectorstoreIndexCreator
|
|
| 9 |
from langchain.llms import OpenAI
|
| 10 |
from langchain.embeddings import OpenAIEmbeddings
|
| 11 |
from langchain.vectorstores.chroma import Chroma
|
| 12 |
-
import constants
|
| 13 |
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
PERSIST = False
|
| 17 |
|
|
@@ -28,7 +29,7 @@ else:
|
|
| 28 |
index = VectorstoreIndexCreator().from_loaders([loader])
|
| 29 |
|
| 30 |
use_gpt_4 = True
|
| 31 |
-
model_name = "gpt-4" if use_gpt_4 else "gpt-3.5-turbo"
|
| 32 |
chain = ConversationalRetrievalChain.from_llm(llm=ChatOpenAI(model=model_name),
|
| 33 |
retriever=index.vectorstore.as_retriever(search_kwargs={"k": 1}))
|
| 34 |
|
|
@@ -44,6 +45,14 @@ def answer_question(question):
|
|
| 44 |
|
| 45 |
iface = gr.Interface(
|
| 46 |
fn=answer_question,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
inputs="text",
|
| 48 |
outputs="text",
|
| 49 |
title="Demo IA Conversacional",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import openai
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
from langchain.chains import ConversationalRetrievalChain
|
| 6 |
from langchain.chat_models import ChatOpenAI
|
| 7 |
from langchain.document_loaders import DirectoryLoader
|
|
|
|
| 10 |
from langchain.llms import OpenAI
|
| 11 |
from langchain.embeddings import OpenAIEmbeddings
|
| 12 |
from langchain.vectorstores.chroma import Chroma
|
|
|
|
| 13 |
|
| 14 |
+
load_dotenv()
|
| 15 |
+
os.getenv("OPENAI_API_KEY")
|
| 16 |
|
| 17 |
PERSIST = False
|
| 18 |
|
|
|
|
| 29 |
index = VectorstoreIndexCreator().from_loaders([loader])
|
| 30 |
|
| 31 |
use_gpt_4 = True
|
| 32 |
+
model_name = "gpt-4" if use_gpt_4 else "gpt-3.5-turbo-16k"
|
| 33 |
chain = ConversationalRetrievalChain.from_llm(llm=ChatOpenAI(model=model_name),
|
| 34 |
retriever=index.vectorstore.as_retriever(search_kwargs={"k": 1}))
|
| 35 |
|
|
|
|
| 45 |
|
| 46 |
iface = gr.Interface(
|
| 47 |
fn=answer_question,
|
| 48 |
+
examples=[
|
| 49 |
+
["¿Quien eres?"],
|
| 50 |
+
["¿Cómo te llamas?"],
|
| 51 |
+
["¿Cómo puedes ayudarme?"],
|
| 52 |
+
["¿Qué puedo hacer si perdí mi contraseña?"],
|
| 53 |
+
["¿Qué puedo hacer si perdí mi tarjeta de cŕedito?"],
|
| 54 |
+
["Genera un reporte o lista de pasos de toda la info que necesito para abrir una cuenta"],
|
| 55 |
+
],
|
| 56 |
inputs="text",
|
| 57 |
outputs="text",
|
| 58 |
title="Demo IA Conversacional",
|
main_llama.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
import openai
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
from llama_index import SimpleDirectoryReader, VectorStoreIndex, load_index_from_storage
|
| 10 |
+
from llama_index.indices.service_context import ServiceContext
|
| 11 |
+
from llama_index.llms import OpenAI
|
| 12 |
+
from llama_index.node_parser import SimpleNodeParser
|
| 13 |
+
from llama_index.node_parser.extractors import (
|
| 14 |
+
MetadataExtractor,
|
| 15 |
+
SummaryExtractor,
|
| 16 |
+
QuestionsAnsweredExtractor,
|
| 17 |
+
TitleExtractor,
|
| 18 |
+
KeywordExtractor,
|
| 19 |
+
)
|
| 20 |
+
from llama_index.storage.storage_context import StorageContext
|
| 21 |
+
from llama_index.text_splitter import TokenTextSplitter
|
| 22 |
+
|
| 23 |
+
# loads dotenv lib to retrieve API keys from .env file
|
| 24 |
+
load_dotenv()
|
| 25 |
+
|
| 26 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 27 |
+
|
| 28 |
+
# enable INFO level logging
|
| 29 |
+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
| 30 |
+
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
|
| 31 |
+
|
| 32 |
+
# define LLM service
|
| 33 |
+
llm = OpenAI(temperature=0.1, model_name="gpt-3.5-turbo-16k", max_tokens=512)
|
| 34 |
+
service_context = ServiceContext.from_defaults(llm=llm)
|
| 35 |
+
|
| 36 |
+
# construct text splitter to split texts into chunks for processing
|
| 37 |
+
text_splitter = TokenTextSplitter(separator=" ", chunk_size=512, chunk_overlap=128)
|
| 38 |
+
|
| 39 |
+
# set the global service context object, avoiding passing service_context when building the index
|
| 40 |
+
from llama_index import set_global_service_context
|
| 41 |
+
|
| 42 |
+
set_global_service_context(service_context)
|
| 43 |
+
|
| 44 |
+
# create metadata extractor
|
| 45 |
+
metadata_extractor = MetadataExtractor(
|
| 46 |
+
extractors=[
|
| 47 |
+
TitleExtractor(nodes=1, llm=llm),
|
| 48 |
+
QuestionsAnsweredExtractor(questions=3, llm=llm),
|
| 49 |
+
SummaryExtractor(summaries=["prev", "self"], llm=llm),
|
| 50 |
+
KeywordExtractor(keywords=10, llm=llm)
|
| 51 |
+
],
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# create node parser to parse nodes from document
|
| 55 |
+
node_parser = SimpleNodeParser(
|
| 56 |
+
text_splitter=text_splitter,
|
| 57 |
+
metadata_extractor=metadata_extractor,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# loading documents
|
| 61 |
+
documents_2023 = SimpleDirectoryReader(input_files=["data/data.pdf"], filename_as_id=True).load_data()
|
| 62 |
+
print(f"loaded data with {len(documents_2023)} pages")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def load_index():
|
| 66 |
+
try:
|
| 67 |
+
# load storage context
|
| 68 |
+
storage_context = StorageContext.from_defaults(persist_dir="./storage")
|
| 69 |
+
# try to load the index from storage
|
| 70 |
+
index = load_index_from_storage(storage_context)
|
| 71 |
+
logging.info("Index loaded from storage.")
|
| 72 |
+
|
| 73 |
+
except FileNotFoundError:
|
| 74 |
+
# if index not found, create a new one
|
| 75 |
+
logging.info("Index not found. Creating a new one...")
|
| 76 |
+
|
| 77 |
+
nodes_2023 = node_parser.get_nodes_from_documents(documents_2023)
|
| 78 |
+
print(f"loaded nodes_2022 with {len(nodes_2023)} nodes")
|
| 79 |
+
|
| 80 |
+
# print metadata in json format
|
| 81 |
+
for node in nodes_2023:
|
| 82 |
+
metadata_json = json.dumps(node.metadata, indent=4) # Convert metadata to formatted JSON
|
| 83 |
+
print(metadata_json)
|
| 84 |
+
|
| 85 |
+
# based on the nodes and service_context, create index
|
| 86 |
+
index = VectorStoreIndex(nodes=nodes_2023, service_context=service_context)
|
| 87 |
+
# Persist index to disk
|
| 88 |
+
index.storage_context.persist()
|
| 89 |
+
logging.info("New index created and persisted to storage.")
|
| 90 |
+
|
| 91 |
+
return index
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def data_querying(input_text):
|
| 95 |
+
# Load index
|
| 96 |
+
index = load_index()
|
| 97 |
+
|
| 98 |
+
# queries the index with the input text
|
| 99 |
+
response = index.as_query_engine().query(input_text)
|
| 100 |
+
|
| 101 |
+
return response.response
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
iface = gr.Interface(fn=data_querying,
|
| 105 |
+
inputs=gr.components.Textbox(lines=3, label="Inserte su pregunta aquí"),
|
| 106 |
+
outputs=gr.components.Textbox(lines=3, label="Respuesta"),
|
| 107 |
+
examples=[
|
| 108 |
+
["¿Quien eres?"],
|
| 109 |
+
["¿Cómo te llamas?"],
|
| 110 |
+
["¿Cómo puedes ayudarme?"],
|
| 111 |
+
["¿Qué puedo hacer si perdí mi contraseña?"],
|
| 112 |
+
["¿Qué puedo hacer si perdí mi tarjeta de cŕedito?"],
|
| 113 |
+
["Genera un reporte o lista de pasos de toda la info que necesito para abrir una cuenta"],
|
| 114 |
+
],
|
| 115 |
+
title="Demo IA Conversacional",
|
| 116 |
+
description="Pregúntame lo que quieras, te responderé con lo que sé.")
|
| 117 |
+
|
| 118 |
+
iface.launch(share=False)
|
persist/c3d7124b-a896-4968-81e2-e8a8ded24596/data_level0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f18abd8c514282db82706e52b0a33ed659cd534e925a6f149deb7af9ce34bd8e
|
| 3 |
+
size 6284000
|
persist/c3d7124b-a896-4968-81e2-e8a8ded24596/header.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:effaa959ce2b30070fdafc2fe82096fc46e4ee7561b75920dd3ce43d09679b21
|
| 3 |
+
size 100
|
persist/c3d7124b-a896-4968-81e2-e8a8ded24596/length.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4594b8794766e04a14dc59e4d6da820fe58db2da4e232f3d233f4a6e08d9c4c9
|
| 3 |
+
size 4000
|
persist/c3d7124b-a896-4968-81e2-e8a8ded24596/link_lists.bin
ADDED
|
File without changes
|
persist/chroma.sqlite3
ADDED
|
Binary file (164 kB). View file
|
|
|
requirements.txt
CHANGED
|
@@ -9,4 +9,14 @@ tiktoken==0.4.0
|
|
| 9 |
youtube-transcript-api==0.6.1
|
| 10 |
faiss-cpu
|
| 11 |
gradio
|
| 12 |
-
unstructured
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
youtube-transcript-api==0.6.1
|
| 10 |
faiss-cpu
|
| 11 |
gradio
|
| 12 |
+
unstructured
|
| 13 |
+
chromadb
|
| 14 |
+
llama-index==0.8.2
|
| 15 |
+
transformers
|
| 16 |
+
span-marker
|
| 17 |
+
nltk
|
| 18 |
+
llama-hub
|
| 19 |
+
tesseract
|
| 20 |
+
pytesseract
|
| 21 |
+
python-dotenv
|
| 22 |
+
PyCryptodome
|
storage/docstore.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"docstore/data": {"c00d29a5-44d9-46f4-a696-6931fda2a634": {"__data__": {"id_": "c00d29a5-44d9-46f4-a696-6931fda2a634", "embedding": null, "metadata": {"page_label": "1", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. What is the interest rate for the EstrellaBank Savings Account?\n2. What are the benefits of investing in the Golden Mutual Funds?\n3. What types of loans does Banco Estrella offer for personal needs and home purchases?", "section_summary": "The section titled \"BANCO ESTRELLA: TU GUIA FINANCIERA\" provides information about Banco Estrella and its services. The section includes an introduction to EstrellaBot, the bank's artificial intelligence designed to provide real-time information and assistance. The section also highlights the bank's mission and vision, which is to provide brilliant financial solutions and become a leader in innovation and customer service. The section then goes on to list the bank's products and services, including different types of bank accounts, investment options such as mutual funds and fixed deposits, and various types of loans including personal and mortgage loans.", "excerpt_keywords": "Banco Estrella, gu\u00eda financiera, EstrellaBot, servicios, productos, cuentas bancarias, cuenta corriente, cuenta de ahorro estelares, opciones de inversi\u00f3n, fondos mutuos dorados, dep\u00f3sitos a plazo, pr\u00e9stamos personales, pr\u00e9stamos hipotecarios."}, "excluded_embed_metadata_keys": [], "excluded_llm_metadata_keys": ["questions_this_excerpt_can_answer"], "relationships": {"1": {"node_id": "data/data.pdf_part_0", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "e4ef0339ff318f700aacfc60cacb80d7f80977ac83efc452d4469c4915e43760"}, "3": {"node_id": "a7c870ee-7ac3-4827-b495-007842e162fd", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "59cc7de775ecfc145f9f0f9ae666ccc7a883af518da2750eb7ea5d8af6e93838"}}, "hash": "4598df404e1cfdbac23051e4e7c6f14728bba69cb7c26e584efb42333a92ac3c", "text": "BANCO ESTRELLA: TU GUIA FINANCIERA\n \nSOBRE M\u00cd - EL BOT DEL BANCO ESTRELLA\n \n\u00a1Hola! Soy EstrellaBot, la inteligencia artificial del Banco Estrella. Fui dise\u00f1ado con el prop\u00f3sito de ofrecerte\ninformaci\u00f3n y respuestas en tiempo real sobre nuestros servicios y productos. Mi misi\u00f3n es que tu experiencia\ncon nosotros sea eficiente y satisfactoria. Si hay algo que desees saber, \u00a1aqu\u00ed estoy para ayudarte!\n \nNUESTRA ESENCIA\n \nNombre del banco: Banco Estrella.\nMisi\u00f3n: Facilitar soluciones financieras brillantes, orientadas a cumplir tus objetivos y sue\u00f1os.\nVisi\u00f3n: Aspiramos a ser el banco l\u00edder en innovaci\u00f3n y servicio al cliente, creciendo junto a ti.\nPRODUCTOS Y SERVICIOS\n \nCuentas Bancarias:\n \nCuenta Corriente: Con acceso 24/7 a trav\u00e9s de nuestra plataforma en l\u00ednea, sin comisiones por manejo.\nCuenta de Ahorro Estelares: Tasa de inter\u00e9s del 3.5% anual, y una tarjeta de d\u00e9bito incluida sin coste adicional.\nOpciones de Inversi\u00f3n:\n \nFondos Mutuos Dorados: Diversifica tus inversiones y disfruta de rentabilidades entre 5-8% anual.\nDep\u00f3sitos a Plazo: Elige la duraci\u00f3n que prefieras y obt\u00e9n tasas de inter\u00e9s competitivas.\nPr\u00e9stamos:\n \nPr\u00e9stamos Personales: Soluciones personalizadas para que cumplas tus metas.\nHipotecarios: Haz realidad la casa de tus sue\u00f1os con nuestro", "start_char_idx": null, "end_char_idx": null, "text_template": "[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n", "metadata_template": "{key}: {value}", "metadata_seperator": "\n"}, "__type__": "1"}, "a7c870ee-7ac3-4827-b495-007842e162fd": {"__data__": {"id_": "a7c870ee-7ac3-4827-b495-007842e162fd", "embedding": null, "metadata": {"page_label": "1", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. What are the interest rates for the Fondos Mutuos Dorados offered by Banco Estrella?\n2. What types of loans does Banco Estrella offer for personal and business needs?\n3. What security measures does Banco Estrella have in place to protect customer data and transactions?", "prev_section_summary": "The section titled \"BANCO ESTRELLA: TU GUIA FINANCIERA\" provides information about Banco Estrella and its services. The section includes an introduction to EstrellaBot, the bank's artificial intelligence designed to provide real-time information and assistance. The section also highlights the bank's mission and vision, which is to provide brilliant financial solutions and become a leader in innovation and customer service. The section then goes on to list the bank's products and services, including different types of bank accounts, investment options such as mutual funds and fixed deposits, and various types of loans including personal and mortgage loans.", "section_summary": "The section discusses various financial products and services offered by the company. The key topics include:\n\n1. Fondos Mutuos Dorados: These are mutual funds that offer diversification and annual returns between 5-8%.\n\n2. Dep\u00f3sitos a Plazo: Customers can choose the duration of their fixed-term deposits and earn competitive interest rates.\n\n3. Pr\u00e9stamos: The company offers personalized solutions for personal loans, mortgage loans for purchasing a house, and financing options for businesses.\n\n4. Tarjetas de Cr\u00e9dito: The company offers two credit card options - Tarjeta Estrella and Tarjeta Estrella Gold, with different benefits and rewards programs.\n\n5. PLATAFORMA DIGITAL: The company provides online banking services, a mobile application for banking on the go, and virtual assistance for customer queries.\n\n6. SEGURIDAD Y CONFIANZA: The company emphasizes its use of advanced technology to protect customer data and transactions, along with features like alerts and two-step authentication for added security.\n\n7. SOPORTE Y CONTACTO: The company provides customer support services during specific hours on weekdays.\n\nOverall, the section highlights the range of financial products and services offered by the company, along with its focus on security, convenience, and customer support.", "excerpt_keywords": "Fondos Mutuos Dorados, Diversificaci\u00f3n, Rentabilidades, Dep\u00f3sitos a Plazo, Tasas de inter\u00e9s, Pr\u00e9stamos Personales, Pr\u00e9stamos Hipotecarios, Pr\u00e9stamos para Empresas, Tarjeta Estrella, Tarjeta Estrella Gold, Banca en l\u00ednea, Aplicaci\u00f3n m\u00f3vil, Asistencia virtual, Seguridad, Confianza, Protecci\u00f3n, Alertas, Autenticaci\u00f3n, Soporte, Contacto, Atenci\u00f3n al cliente."}, "excluded_embed_metadata_keys": [], "excluded_llm_metadata_keys": ["questions_this_excerpt_can_answer"], "relationships": {"1": {"node_id": "data/data.pdf_part_0", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "e4ef0339ff318f700aacfc60cacb80d7f80977ac83efc452d4469c4915e43760"}, "2": {"node_id": "c00d29a5-44d9-46f4-a696-6931fda2a634", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "4598df404e1cfdbac23051e4e7c6f14728bba69cb7c26e584efb42333a92ac3c"}, "3": {"node_id": "7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "42f9c5d6dbd524c3aae3534b68734a675292cb004e5ec65c649f0fc7e8d30b75"}}, "hash": "59cc7de775ecfc145f9f0f9ae666ccc7a883af518da2750eb7ea5d8af6e93838", "text": "Fondos Mutuos Dorados: Diversifica tus inversiones y disfruta de rentabilidades entre 5-8% anual.\nDep\u00f3sitos a Plazo: Elige la duraci\u00f3n que prefieras y obt\u00e9n tasas de inter\u00e9s competitivas.\nPr\u00e9stamos:\n \nPr\u00e9stamos Personales: Soluciones personalizadas para que cumplas tus metas.\nHipotecarios: Haz realidad la casa de tus sue\u00f1os con nuestro financiamiento.\nPara Empresas: Apoyamos el crecimiento de tu negocio con financiamiento y consultor\u00eda especializada.\nTarjetas de Cr\u00e9dito:\n \nTarjeta Estrella: Perfecta para tu d\u00eda a d\u00eda, con un programa de recompensas excepcional.\nTarjeta Estrella Gold: Beneficios premium y acceso a experiencias exclusivas.\nPLATAFORMA DIGITAL\n \nBanca en l\u00ednea: Accede a tus cuentas, realiza transferencias y consulta tu historial de transacciones.\nAplicaci\u00f3n m\u00f3vil: Una banca m\u00f3vil completa en la palma de tu mano. Paga facturas, consulta saldos y mucho\nm\u00e1s.\nAsistencia virtual: Estoy aqu\u00ed, listo para ayudarte con cualquier consulta que tengas.\nSEGURIDAD Y CONFIANZA\n \nProtecci\u00f3n: Usamos tecnolog\u00eda avanzada para proteger tus datos y transacciones.\nAlertas: Recibe notificaciones sobre la actividad en tus cuentas y mantente siempre informado.\nAutenticaci\u00f3n: Procesos de verificaci\u00f3n de dos pasos, garantizando tu seguridad.\nSOPORTE Y CONTACTO\n \nAtenci\u00f3n al cliente: Disponibles de Lunes a Viernes de 8am a 3pm al", "start_char_idx": null, "end_char_idx": null, "text_template": "[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n", "metadata_template": "{key}: {value}", "metadata_seperator": "\n"}, "__type__": "1"}, "7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f": {"__data__": {"id_": "7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f", "embedding": null, "metadata": {"page_label": "1", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. What technology does Banco Estrella use to protect customer data and transactions?\n2. What are the available customer support hours for Banco Estrella?\n3. How can customers find their nearest Banco Estrella branch?", "prev_section_summary": "The section discusses various financial products and services offered by the company. The key topics include:\n\n1. Fondos Mutuos Dorados: These are mutual funds that offer diversification and annual returns between 5-8%.\n\n2. Dep\u00f3sitos a Plazo: Customers can choose the duration of their fixed-term deposits and earn competitive interest rates.\n\n3. Pr\u00e9stamos: The company offers personalized solutions for personal loans, mortgage loans for purchasing a house, and financing options for businesses.\n\n4. Tarjetas de Cr\u00e9dito: The company offers two credit card options - Tarjeta Estrella and Tarjeta Estrella Gold, with different benefits and rewards programs.\n\n5. PLATAFORMA DIGITAL: The company provides online banking services, a mobile application for banking on the go, and virtual assistance for customer queries.\n\n6. SEGURIDAD Y CONFIANZA: The company emphasizes its use of advanced technology to protect customer data and transactions, along with features like alerts and two-step authentication for added security.\n\n7. SOPORTE Y CONTACTO: The company provides customer support services during specific hours on weekdays.\n\nOverall, the section highlights the range of financial products and services offered by the company, along with its focus on security, convenience, and customer support.", "section_summary": "The key topics of this section are data and transaction protection, alerts, authentication, customer support, and contact information. The entities mentioned include the bank's advanced technology for data protection, notifications for account activity, two-step verification for security, customer service availability, branch locations, and emergency contact information.", "excerpt_keywords": "protecci\u00f3n, tecnolog\u00eda avanzada, datos, transacciones, alertas, actividad, cuentas, informado, autenticaci\u00f3n, verificaci\u00f3n, seguridad, soporte, contacto, atenci\u00f3n al cliente, horario, sucursales, b\u00fasqueda, emergencias, tarjeta, actividad fraudulenta"}, "excluded_embed_metadata_keys": [], "excluded_llm_metadata_keys": ["questions_this_excerpt_can_answer"], "relationships": {"1": {"node_id": "data/data.pdf_part_0", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "e4ef0339ff318f700aacfc60cacb80d7f80977ac83efc452d4469c4915e43760"}, "2": {"node_id": "a7c870ee-7ac3-4827-b495-007842e162fd", "node_type": null, "metadata": {"page_label": "1", "file_name": "data.pdf"}, "hash": "59cc7de775ecfc145f9f0f9ae666ccc7a883af518da2750eb7ea5d8af6e93838"}}, "hash": "42f9c5d6dbd524c3aae3534b68734a675292cb004e5ec65c649f0fc7e8d30b75", "text": "Protecci\u00f3n: Usamos tecnolog\u00eda avanzada para proteger tus datos y transacciones.\nAlertas: Recibe notificaciones sobre la actividad en tus cuentas y mantente siempre informado.\nAutenticaci\u00f3n: Procesos de verificaci\u00f3n de dos pasos, garantizando tu seguridad.\nSOPORTE Y CONTACTO\n \nAtenci\u00f3n al cliente: Disponibles de Lunes a Viernes de 8am a 3pm al 123-456-7890 o en\nmail@bancoestrella.com.\nSucursales: Encuentra tu sucursal m\u00e1s cercana usando nuestra funci\u00f3n de b\u00fasqueda en la app o sitio web.\nEmergencias: Si pierdes tu tarjeta o sospechas de actividad fraudulenta, contacta inmediatamente al 123-456-\n7890.", "start_char_idx": null, "end_char_idx": null, "text_template": "[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n", "metadata_template": "{key}: {value}", "metadata_seperator": "\n"}, "__type__": "1"}, "ea3fda34-2f85-489d-a5fb-761bc2371c4e": {"__data__": {"id_": "ea3fda34-2f85-489d-a5fb-761bc2371c4e", "embedding": null, "metadata": {"page_label": "2", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. \u00bfCu\u00e1les son los requisitos para abrir una cuenta en Banco Estrella?\n2. \u00bfQu\u00e9 opciones de transferencia de dinero ofrece Banco Estrella?\n3. \u00bfC\u00f3mo puedo solicitar un aumento en mi l\u00ednea de cr\u00e9dito en Banco Estrella?", "prev_section_summary": "The key topics of this section are data and transaction protection, alerts, authentication, customer support, and contact information. The entities mentioned include the bank's advanced technology for data protection, notifications for account activity, two-step verification for security, customer service availability, branch locations, and emergency contact information.", "section_summary": "The key topics of the section are opening an account, transferring money to other banks, increasing credit limit, and the emergency contact number. The entities mentioned are the bank and the customers.", "excerpt_keywords": "abrir cuenta, identificaci\u00f3n, comprobante de domicilio, transferencias, plataforma, bancos, l\u00ednea de cr\u00e9dito, perfil, necesidades, n\u00famero de emergencia"}, "excluded_embed_metadata_keys": [], "excluded_llm_metadata_keys": ["questions_this_excerpt_can_answer"], "relationships": {"1": {"node_id": "data/data.pdf_part_1", "node_type": null, "metadata": {"page_label": "2", "file_name": "data.pdf"}, "hash": "e36812fd2f5c23bd81368fc500ca5dbd1fd974fcf8c6969d7d745f6b374abbb8"}}, "hash": "603b77b5977c7cada457baecde64557a03314a9c502decec36fe6b6cae0ce5d6", "text": "PREGUNTAS FRECUENTES\n \n\u00bfC\u00f3mo abro una cuenta?: Ven con tu identificaci\u00f3n y comprobante de domicilio a\ncualquiera de nuestras sucursales.\n\u00bfPuedo transferir dinero a otros bancos?: S\u00ed, a trav\u00e9s de nuestra plataforma puedes\nhacer transferencias nacionales e internacionales.\n\u00bfC\u00f3mo incremento mi l\u00ednea de cr\u00e9dito?: Cont\u00e1ctanos y evaluaremos tu perfil para\nofrecerte una l\u00ednea de cr\u00e9dito que se adapte a tus necesidades.\n \n \nEl n\u00famero de emergencia es: 123-456-7890", "start_char_idx": null, "end_char_idx": null, "text_template": "[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n", "metadata_template": "{key}: {value}", "metadata_seperator": "\n"}, "__type__": "1"}}, "docstore/ref_doc_info": {"data/data.pdf_part_0": {"node_ids": ["c00d29a5-44d9-46f4-a696-6931fda2a634", "a7c870ee-7ac3-4827-b495-007842e162fd", "7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f"], "metadata": {"page_label": "1", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. What is the interest rate for the EstrellaBank Savings Account?\n2. What are the benefits of investing in the Golden Mutual Funds?\n3. What types of loans does Banco Estrella offer for personal needs and home purchases?", "section_summary": "The section titled \"BANCO ESTRELLA: TU GUIA FINANCIERA\" provides information about Banco Estrella and its services. The section includes an introduction to EstrellaBot, the bank's artificial intelligence designed to provide real-time information and assistance. The section also highlights the bank's mission and vision, which is to provide brilliant financial solutions and become a leader in innovation and customer service. The section then goes on to list the bank's products and services, including different types of bank accounts, investment options such as mutual funds and fixed deposits, and various types of loans including personal and mortgage loans.", "excerpt_keywords": "Banco Estrella, gu\u00eda financiera, EstrellaBot, servicios, productos, cuentas bancarias, cuenta corriente, cuenta de ahorro estelares, opciones de inversi\u00f3n, fondos mutuos dorados, dep\u00f3sitos a plazo, pr\u00e9stamos personales, pr\u00e9stamos hipotecarios."}}, "data/data.pdf_part_1": {"node_ids": ["ea3fda34-2f85-489d-a5fb-761bc2371c4e"], "metadata": {"page_label": "2", "file_name": "data.pdf", "document_title": "Banco Estrella: Tu Gu\u00eda Financiera", "questions_this_excerpt_can_answer": "1. \u00bfCu\u00e1les son los requisitos para abrir una cuenta en Banco Estrella?\n2. \u00bfQu\u00e9 opciones de transferencia de dinero ofrece Banco Estrella?\n3. \u00bfC\u00f3mo puedo solicitar un aumento en mi l\u00ednea de cr\u00e9dito en Banco Estrella?", "prev_section_summary": "The key topics of this section are data and transaction protection, alerts, authentication, customer support, and contact information. The entities mentioned include the bank's advanced technology for data protection, notifications for account activity, two-step verification for security, customer service availability, branch locations, and emergency contact information.", "section_summary": "The key topics of the section are opening an account, transferring money to other banks, increasing credit limit, and the emergency contact number. The entities mentioned are the bank and the customers.", "excerpt_keywords": "abrir cuenta, identificaci\u00f3n, comprobante de domicilio, transferencias, plataforma, bancos, l\u00ednea de cr\u00e9dito, perfil, necesidades, n\u00famero de emergencia"}}}, "docstore/metadata": {"c00d29a5-44d9-46f4-a696-6931fda2a634": {"doc_hash": "4598df404e1cfdbac23051e4e7c6f14728bba69cb7c26e584efb42333a92ac3c", "ref_doc_id": "data/data.pdf_part_0"}, "a7c870ee-7ac3-4827-b495-007842e162fd": {"doc_hash": "59cc7de775ecfc145f9f0f9ae666ccc7a883af518da2750eb7ea5d8af6e93838", "ref_doc_id": "data/data.pdf_part_0"}, "7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f": {"doc_hash": "42f9c5d6dbd524c3aae3534b68734a675292cb004e5ec65c649f0fc7e8d30b75", "ref_doc_id": "data/data.pdf_part_0"}, "ea3fda34-2f85-489d-a5fb-761bc2371c4e": {"doc_hash": "603b77b5977c7cada457baecde64557a03314a9c502decec36fe6b6cae0ce5d6", "ref_doc_id": "data/data.pdf_part_1"}}}
|
storage/graph_store.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"graph_dict": {}}
|
storage/index_store.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"index_store/data": {"b8733163-d7b7-46dd-9007-d7c4b33d3cb0": {"__type__": "vector_store", "__data__": "{\"index_id\": \"b8733163-d7b7-46dd-9007-d7c4b33d3cb0\", \"summary\": null, \"nodes_dict\": {\"c00d29a5-44d9-46f4-a696-6931fda2a634\": \"c00d29a5-44d9-46f4-a696-6931fda2a634\", \"a7c870ee-7ac3-4827-b495-007842e162fd\": \"a7c870ee-7ac3-4827-b495-007842e162fd\", \"7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f\": \"7ec0ccf2-b0f3-4c35-8cda-857c1b402e8f\", \"ea3fda34-2f85-489d-a5fb-761bc2371c4e\": \"ea3fda34-2f85-489d-a5fb-761bc2371c4e\"}, \"doc_id_dict\": {}, \"embeddings_dict\": {}}"}}}
|
storage/vector_store.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
venv/bin/accelerate
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from accelerate.commands.accelerate_cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/accelerate-config
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from accelerate.commands.config import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/accelerate-launch
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from accelerate.commands.launch import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/cmake
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from cmake import cmake
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(cmake())
|
venv/bin/convert-caffe2-to-onnx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from caffe2.python.onnx.bin.conversion import caffe2_to_onnx
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(caffe2_to_onnx())
|
venv/bin/convert-onnx-to-caffe2
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from caffe2.python.onnx.bin.conversion import onnx_to_caffe2
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(onnx_to_caffe2())
|
venv/bin/cpack
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from cmake import cpack
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(cpack())
|
venv/bin/ctest
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from cmake import ctest
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(ctest())
|
venv/bin/datasets-cli
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from datasets.commands.datasets_cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/evaluate-cli
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from evaluate.commands.evaluate_cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/flask
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from flask.cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/get_gprof
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
#
|
| 3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
| 4 |
+
# Copyright (c) 2008-2016 California Institute of Technology.
|
| 5 |
+
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
|
| 6 |
+
# License: 3-clause BSD. The full license text is available at:
|
| 7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
| 8 |
+
'''
|
| 9 |
+
build profile graph for the given instance
|
| 10 |
+
|
| 11 |
+
running:
|
| 12 |
+
$ get_gprof <args> <instance>
|
| 13 |
+
|
| 14 |
+
executes:
|
| 15 |
+
gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png
|
| 16 |
+
|
| 17 |
+
where:
|
| 18 |
+
<args> are arguments for gprof2dot, such as "-n 5 -e 5"
|
| 19 |
+
<instance> is code to create the instance to profile
|
| 20 |
+
<type> is the class of the instance (i.e. type(instance))
|
| 21 |
+
|
| 22 |
+
For example:
|
| 23 |
+
$ get_gprof -n 5 -e 1 "import numpy; numpy.array([1,2])"
|
| 24 |
+
|
| 25 |
+
will create 'ndarray.call.png' with the profile graph for numpy.array([1,2]),
|
| 26 |
+
where '-n 5' eliminates nodes below 5% threshold, similarly '-e 1' eliminates
|
| 27 |
+
edges below 1% threshold
|
| 28 |
+
'''
|
| 29 |
+
|
| 30 |
+
import sys
|
| 31 |
+
# grab args for gprof2dot
|
| 32 |
+
args = sys.argv[1:-1]
|
| 33 |
+
args = ' '.join(args)
|
| 34 |
+
# last arg builds the object
|
| 35 |
+
obj = sys.argv[-1]
|
| 36 |
+
obj = obj.split(';')
|
| 37 |
+
# multi-line prep for generating an instance
|
| 38 |
+
for line in obj[:-1]:
|
| 39 |
+
exec(line)
|
| 40 |
+
# one-line generation of an instance
|
| 41 |
+
obj = eval(obj[-1])
|
| 42 |
+
|
| 43 |
+
# get object 'name'
|
| 44 |
+
objtype = type(obj)
|
| 45 |
+
name = getattr(objtype, '__name__', getattr(objtype, '__class__', objtype))
|
| 46 |
+
|
| 47 |
+
# profile dumping an object
|
| 48 |
+
import dill
|
| 49 |
+
import os
|
| 50 |
+
import cProfile
|
| 51 |
+
#name = os.path.splitext(os.path.basename(__file__))[0]
|
| 52 |
+
cProfile.run("dill.dumps(obj)", filename="%s.prof" % name)
|
| 53 |
+
msg = "gprof2dot -f pstats %s %s.prof | dot -Tpng -o %s.call.png" % (args, name, name)
|
| 54 |
+
os.system(msg)
|
| 55 |
+
|
| 56 |
+
# get stats
|
| 57 |
+
f_prof = "%s.prof" % name
|
| 58 |
+
import pstats
|
| 59 |
+
stats = pstats.Stats(f_prof, stream=sys.stdout)
|
| 60 |
+
stats.strip_dirs().sort_stats('cumtime')
|
| 61 |
+
stats.print_stats(20) #XXX: save to file instead of print top 20?
|
| 62 |
+
os.remove(f_prof)
|
venv/bin/get_objgraph
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
#
|
| 3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
| 4 |
+
# Copyright (c) 2008-2016 California Institute of Technology.
|
| 5 |
+
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
|
| 6 |
+
# License: 3-clause BSD. The full license text is available at:
|
| 7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
| 8 |
+
"""
|
| 9 |
+
display the reference paths for objects in ``dill.types`` or a .pkl file
|
| 10 |
+
|
| 11 |
+
Notes:
|
| 12 |
+
the generated image is useful in showing the pointer references in
|
| 13 |
+
objects that are or can be pickled. Any object in ``dill.objects``
|
| 14 |
+
listed in ``dill.load_types(picklable=True, unpicklable=True)`` works.
|
| 15 |
+
|
| 16 |
+
Examples::
|
| 17 |
+
|
| 18 |
+
$ get_objgraph ArrayType
|
| 19 |
+
Image generated as ArrayType.png
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
import dill as pickle
|
| 23 |
+
#pickle.debug.trace(True)
|
| 24 |
+
#import pickle
|
| 25 |
+
|
| 26 |
+
# get all objects for testing
|
| 27 |
+
from dill import load_types
|
| 28 |
+
load_types(pickleable=True,unpickleable=True)
|
| 29 |
+
from dill import objects
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
import sys
|
| 33 |
+
if len(sys.argv) != 2:
|
| 34 |
+
print ("Please provide exactly one file or type name (e.g. 'IntType')")
|
| 35 |
+
msg = "\n"
|
| 36 |
+
for objtype in list(objects.keys())[:40]:
|
| 37 |
+
msg += objtype + ', '
|
| 38 |
+
print (msg + "...")
|
| 39 |
+
else:
|
| 40 |
+
objtype = str(sys.argv[-1])
|
| 41 |
+
try:
|
| 42 |
+
obj = objects[objtype]
|
| 43 |
+
except KeyError:
|
| 44 |
+
obj = pickle.load(open(objtype,'rb'))
|
| 45 |
+
import os
|
| 46 |
+
objtype = os.path.splitext(objtype)[0]
|
| 47 |
+
try:
|
| 48 |
+
import objgraph
|
| 49 |
+
objgraph.show_refs(obj, filename=objtype+'.png')
|
| 50 |
+
except ImportError:
|
| 51 |
+
print ("Please install 'objgraph' to view object graphs")
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
# EOF
|
venv/bin/html2text
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from html2text.cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/lit
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from lit.main import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/pytesseract
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from pytesseract.pytesseract import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/torchrun
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from torch.distributed.run import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/transformers-cli
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import re
|
| 4 |
+
import sys
|
| 5 |
+
from transformers.commands.transformers_cli import main
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
| 8 |
+
sys.exit(main())
|
venv/bin/undill
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/home/draco/PycharmProjects/customChatBotDemo/venv/bin/python
|
| 2 |
+
#
|
| 3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
| 4 |
+
# Copyright (c) 2008-2016 California Institute of Technology.
|
| 5 |
+
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
|
| 6 |
+
# License: 3-clause BSD. The full license text is available at:
|
| 7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
| 8 |
+
"""
|
| 9 |
+
unpickle the contents of a pickled object file
|
| 10 |
+
|
| 11 |
+
Examples::
|
| 12 |
+
|
| 13 |
+
$ undill hello.pkl
|
| 14 |
+
['hello', 'world']
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
if __name__ == '__main__':
|
| 18 |
+
import sys
|
| 19 |
+
import dill
|
| 20 |
+
for file in sys.argv[1:]:
|
| 21 |
+
print (dill.load(open(file,'rb')))
|
| 22 |
+
|
venv/lib/python3.11/site-packages/Crypto/Cipher/AES.py
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# Cipher/AES.py : AES
|
| 4 |
+
#
|
| 5 |
+
# ===================================================================
|
| 6 |
+
# The contents of this file are dedicated to the public domain. To
|
| 7 |
+
# the extent that dedication to the public domain is not available,
|
| 8 |
+
# everyone is granted a worldwide, perpetual, royalty-free,
|
| 9 |
+
# non-exclusive license to exercise all rights associated with the
|
| 10 |
+
# contents of this file for any purpose whatsoever.
|
| 11 |
+
# No rights are reserved.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 14 |
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 15 |
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 16 |
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
| 17 |
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
| 18 |
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 19 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 20 |
+
# SOFTWARE.
|
| 21 |
+
# ===================================================================
|
| 22 |
+
|
| 23 |
+
import sys
|
| 24 |
+
|
| 25 |
+
from Crypto.Cipher import _create_cipher
|
| 26 |
+
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
|
| 27 |
+
VoidPointer, SmartPointer,
|
| 28 |
+
c_size_t, c_uint8_ptr)
|
| 29 |
+
|
| 30 |
+
from Crypto.Util import _cpu_features
|
| 31 |
+
from Crypto.Random import get_random_bytes
|
| 32 |
+
|
| 33 |
+
MODE_ECB = 1 #: Electronic Code Book (:ref:`ecb_mode`)
|
| 34 |
+
MODE_CBC = 2 #: Cipher-Block Chaining (:ref:`cbc_mode`)
|
| 35 |
+
MODE_CFB = 3 #: Cipher Feedback (:ref:`cfb_mode`)
|
| 36 |
+
MODE_OFB = 5 #: Output Feedback (:ref:`ofb_mode`)
|
| 37 |
+
MODE_CTR = 6 #: Counter mode (:ref:`ctr_mode`)
|
| 38 |
+
MODE_OPENPGP = 7 #: OpenPGP mode (:ref:`openpgp_mode`)
|
| 39 |
+
MODE_CCM = 8 #: Counter with CBC-MAC (:ref:`ccm_mode`)
|
| 40 |
+
MODE_EAX = 9 #: :ref:`eax_mode`
|
| 41 |
+
MODE_SIV = 10 #: Synthetic Initialization Vector (:ref:`siv_mode`)
|
| 42 |
+
MODE_GCM = 11 #: Galois Counter Mode (:ref:`gcm_mode`)
|
| 43 |
+
MODE_OCB = 12 #: Offset Code Book (:ref:`ocb_mode`)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
_cproto = """
|
| 47 |
+
int AES_start_operation(const uint8_t key[],
|
| 48 |
+
size_t key_len,
|
| 49 |
+
void **pResult);
|
| 50 |
+
int AES_encrypt(const void *state,
|
| 51 |
+
const uint8_t *in,
|
| 52 |
+
uint8_t *out,
|
| 53 |
+
size_t data_len);
|
| 54 |
+
int AES_decrypt(const void *state,
|
| 55 |
+
const uint8_t *in,
|
| 56 |
+
uint8_t *out,
|
| 57 |
+
size_t data_len);
|
| 58 |
+
int AES_stop_operation(void *state);
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
# Load portable AES
|
| 63 |
+
_raw_aes_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aes",
|
| 64 |
+
_cproto)
|
| 65 |
+
|
| 66 |
+
# Try to load AES with AES NI instructions
|
| 67 |
+
try:
|
| 68 |
+
_raw_aesni_lib = None
|
| 69 |
+
if _cpu_features.have_aes_ni():
|
| 70 |
+
_raw_aesni_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aesni",
|
| 71 |
+
_cproto.replace("AES",
|
| 72 |
+
"AESNI"))
|
| 73 |
+
# _raw_aesni may not have been compiled in
|
| 74 |
+
except OSError:
|
| 75 |
+
pass
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def _create_base_cipher(dict_parameters):
|
| 79 |
+
"""This method instantiates and returns a handle to a low-level
|
| 80 |
+
base cipher. It will absorb named parameters in the process."""
|
| 81 |
+
|
| 82 |
+
use_aesni = dict_parameters.pop("use_aesni", True)
|
| 83 |
+
|
| 84 |
+
try:
|
| 85 |
+
key = dict_parameters.pop("key")
|
| 86 |
+
except KeyError:
|
| 87 |
+
raise TypeError("Missing 'key' parameter")
|
| 88 |
+
|
| 89 |
+
if len(key) not in key_size:
|
| 90 |
+
raise ValueError("Incorrect AES key length (%d bytes)" % len(key))
|
| 91 |
+
|
| 92 |
+
if use_aesni and _raw_aesni_lib:
|
| 93 |
+
start_operation = _raw_aesni_lib.AESNI_start_operation
|
| 94 |
+
stop_operation = _raw_aesni_lib.AESNI_stop_operation
|
| 95 |
+
else:
|
| 96 |
+
start_operation = _raw_aes_lib.AES_start_operation
|
| 97 |
+
stop_operation = _raw_aes_lib.AES_stop_operation
|
| 98 |
+
|
| 99 |
+
cipher = VoidPointer()
|
| 100 |
+
result = start_operation(c_uint8_ptr(key),
|
| 101 |
+
c_size_t(len(key)),
|
| 102 |
+
cipher.address_of())
|
| 103 |
+
if result:
|
| 104 |
+
raise ValueError("Error %X while instantiating the AES cipher"
|
| 105 |
+
% result)
|
| 106 |
+
return SmartPointer(cipher.get(), stop_operation)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def _derive_Poly1305_key_pair(key, nonce):
|
| 110 |
+
"""Derive a tuple (r, s, nonce) for a Poly1305 MAC.
|
| 111 |
+
|
| 112 |
+
If nonce is ``None``, a new 16-byte nonce is generated.
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
if len(key) != 32:
|
| 116 |
+
raise ValueError("Poly1305 with AES requires a 32-byte key")
|
| 117 |
+
|
| 118 |
+
if nonce is None:
|
| 119 |
+
nonce = get_random_bytes(16)
|
| 120 |
+
elif len(nonce) != 16:
|
| 121 |
+
raise ValueError("Poly1305 with AES requires a 16-byte nonce")
|
| 122 |
+
|
| 123 |
+
s = new(key[:16], MODE_ECB).encrypt(nonce)
|
| 124 |
+
return key[16:], s, nonce
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def new(key, mode, *args, **kwargs):
|
| 128 |
+
"""Create a new AES cipher.
|
| 129 |
+
|
| 130 |
+
Args:
|
| 131 |
+
key(bytes/bytearray/memoryview):
|
| 132 |
+
The secret key to use in the symmetric cipher.
|
| 133 |
+
|
| 134 |
+
It must be 16 (*AES-128)*, 24 (*AES-192*) or 32 (*AES-256*) bytes long.
|
| 135 |
+
|
| 136 |
+
For ``MODE_SIV`` only, it doubles to 32, 48, or 64 bytes.
|
| 137 |
+
mode (a ``MODE_*`` constant):
|
| 138 |
+
The chaining mode to use for encryption or decryption.
|
| 139 |
+
If in doubt, use ``MODE_EAX``.
|
| 140 |
+
|
| 141 |
+
Keyword Args:
|
| 142 |
+
iv (bytes/bytearray/memoryview):
|
| 143 |
+
(Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
|
| 144 |
+
and ``MODE_OPENPGP`` modes).
|
| 145 |
+
|
| 146 |
+
The initialization vector to use for encryption or decryption.
|
| 147 |
+
|
| 148 |
+
For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 16 bytes long.
|
| 149 |
+
|
| 150 |
+
For ``MODE_OPENPGP`` mode only,
|
| 151 |
+
it must be 16 bytes long for encryption
|
| 152 |
+
and 18 bytes for decryption (in the latter case, it is
|
| 153 |
+
actually the *encrypted* IV which was prefixed to the ciphertext).
|
| 154 |
+
|
| 155 |
+
If not provided, a random byte string is generated (you must then
|
| 156 |
+
read its value with the :attr:`iv` attribute).
|
| 157 |
+
|
| 158 |
+
nonce (bytes/bytearray/memoryview):
|
| 159 |
+
(Only applicable for ``MODE_CCM``, ``MODE_EAX``, ``MODE_GCM``,
|
| 160 |
+
``MODE_SIV``, ``MODE_OCB``, and ``MODE_CTR``).
|
| 161 |
+
|
| 162 |
+
A value that must never be reused for any other encryption done
|
| 163 |
+
with this key (except possibly for ``MODE_SIV``, see below).
|
| 164 |
+
|
| 165 |
+
For ``MODE_EAX``, ``MODE_GCM`` and ``MODE_SIV`` there are no
|
| 166 |
+
restrictions on its length (recommended: **16** bytes).
|
| 167 |
+
|
| 168 |
+
For ``MODE_CCM``, its length must be in the range **[7..13]**.
|
| 169 |
+
Bear in mind that with CCM there is a trade-off between nonce
|
| 170 |
+
length and maximum message size. Recommendation: **11** bytes.
|
| 171 |
+
|
| 172 |
+
For ``MODE_OCB``, its length must be in the range **[1..15]**
|
| 173 |
+
(recommended: **15**).
|
| 174 |
+
|
| 175 |
+
For ``MODE_CTR``, its length must be in the range **[0..15]**
|
| 176 |
+
(recommended: **8**).
|
| 177 |
+
|
| 178 |
+
For ``MODE_SIV``, the nonce is optional, if it is not specified,
|
| 179 |
+
then no nonce is being used, which renders the encryption
|
| 180 |
+
deterministic.
|
| 181 |
+
|
| 182 |
+
If not provided, for modes other than ``MODE_SIV``, a random
|
| 183 |
+
byte string of the recommended length is used (you must then
|
| 184 |
+
read its value with the :attr:`nonce` attribute).
|
| 185 |
+
|
| 186 |
+
segment_size (integer):
|
| 187 |
+
(Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
|
| 188 |
+
are segmented in. It must be a multiple of 8.
|
| 189 |
+
If not specified, it will be assumed to be 8.
|
| 190 |
+
|
| 191 |
+
mac_len (integer):
|
| 192 |
+
(Only ``MODE_EAX``, ``MODE_GCM``, ``MODE_OCB``, ``MODE_CCM``)
|
| 193 |
+
Length of the authentication tag, in bytes.
|
| 194 |
+
|
| 195 |
+
It must be even and in the range **[4..16]**.
|
| 196 |
+
The recommended value (and the default, if not specified) is **16**.
|
| 197 |
+
|
| 198 |
+
msg_len (integer):
|
| 199 |
+
(Only ``MODE_CCM``). Length of the message to (de)cipher.
|
| 200 |
+
If not specified, ``encrypt`` must be called with the entire message.
|
| 201 |
+
Similarly, ``decrypt`` can only be called once.
|
| 202 |
+
|
| 203 |
+
assoc_len (integer):
|
| 204 |
+
(Only ``MODE_CCM``). Length of the associated data.
|
| 205 |
+
If not specified, all associated data is buffered internally,
|
| 206 |
+
which may represent a problem for very large messages.
|
| 207 |
+
|
| 208 |
+
initial_value (integer or bytes/bytearray/memoryview):
|
| 209 |
+
(Only ``MODE_CTR``).
|
| 210 |
+
The initial value for the counter. If not present, the cipher will
|
| 211 |
+
start counting from 0. The value is incremented by one for each block.
|
| 212 |
+
The counter number is encoded in big endian mode.
|
| 213 |
+
|
| 214 |
+
counter (object):
|
| 215 |
+
(Only ``MODE_CTR``).
|
| 216 |
+
Instance of ``Crypto.Util.Counter``, which allows full customization
|
| 217 |
+
of the counter block. This parameter is incompatible to both ``nonce``
|
| 218 |
+
and ``initial_value``.
|
| 219 |
+
|
| 220 |
+
use_aesni: (boolean):
|
| 221 |
+
Use Intel AES-NI hardware extensions (default: use if available).
|
| 222 |
+
|
| 223 |
+
Returns:
|
| 224 |
+
an AES object, of the applicable mode.
|
| 225 |
+
"""
|
| 226 |
+
|
| 227 |
+
kwargs["add_aes_modes"] = True
|
| 228 |
+
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
# Size of a data block (in bytes)
|
| 232 |
+
block_size = 16
|
| 233 |
+
# Size of a key (in bytes)
|
| 234 |
+
key_size = (16, 24, 32)
|
venv/lib/python3.11/site-packages/Crypto/Cipher/AES.pyi
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import ByteString, Dict, Optional, Tuple, Union, overload
|
| 2 |
+
from typing_extensions import Literal
|
| 3 |
+
|
| 4 |
+
from Crypto.Cipher._mode_ecb import EcbMode
|
| 5 |
+
from Crypto.Cipher._mode_cbc import CbcMode
|
| 6 |
+
from Crypto.Cipher._mode_cfb import CfbMode
|
| 7 |
+
from Crypto.Cipher._mode_ofb import OfbMode
|
| 8 |
+
from Crypto.Cipher._mode_ctr import CtrMode
|
| 9 |
+
from Crypto.Cipher._mode_openpgp import OpenPgpMode
|
| 10 |
+
from Crypto.Cipher._mode_ccm import CcmMode
|
| 11 |
+
from Crypto.Cipher._mode_eax import EaxMode
|
| 12 |
+
from Crypto.Cipher._mode_gcm import GcmMode
|
| 13 |
+
from Crypto.Cipher._mode_siv import SivMode
|
| 14 |
+
from Crypto.Cipher._mode_ocb import OcbMode
|
| 15 |
+
|
| 16 |
+
MODE_ECB: Literal[1]
|
| 17 |
+
MODE_CBC: Literal[2]
|
| 18 |
+
MODE_CFB: Literal[3]
|
| 19 |
+
MODE_OFB: Literal[5]
|
| 20 |
+
MODE_CTR: Literal[6]
|
| 21 |
+
MODE_OPENPGP: Literal[7]
|
| 22 |
+
MODE_CCM: Literal[8]
|
| 23 |
+
MODE_EAX: Literal[9]
|
| 24 |
+
MODE_SIV: Literal[10]
|
| 25 |
+
MODE_GCM: Literal[11]
|
| 26 |
+
MODE_OCB: Literal[12]
|
| 27 |
+
|
| 28 |
+
# MODE_ECB
|
| 29 |
+
@overload
|
| 30 |
+
def new(key: ByteString,
|
| 31 |
+
mode: Literal[1],
|
| 32 |
+
use_aesni : bool = ...) -> \
|
| 33 |
+
EcbMode: ...
|
| 34 |
+
|
| 35 |
+
# MODE_CBC
|
| 36 |
+
@overload
|
| 37 |
+
def new(key: ByteString,
|
| 38 |
+
mode: Literal[2],
|
| 39 |
+
iv : Optional[ByteString] = ...,
|
| 40 |
+
use_aesni : bool = ...) -> \
|
| 41 |
+
CbcMode: ...
|
| 42 |
+
|
| 43 |
+
@overload
|
| 44 |
+
def new(key: ByteString,
|
| 45 |
+
mode: Literal[2],
|
| 46 |
+
IV : Optional[ByteString] = ...,
|
| 47 |
+
use_aesni : bool = ...) -> \
|
| 48 |
+
CbcMode: ...
|
| 49 |
+
|
| 50 |
+
# MODE_CFB
|
| 51 |
+
@overload
|
| 52 |
+
def new(key: ByteString,
|
| 53 |
+
mode: Literal[3],
|
| 54 |
+
iv : Optional[ByteString] = ...,
|
| 55 |
+
segment_size : int = ...,
|
| 56 |
+
use_aesni : bool = ...) -> \
|
| 57 |
+
CfbMode: ...
|
| 58 |
+
|
| 59 |
+
@overload
|
| 60 |
+
def new(key: ByteString,
|
| 61 |
+
mode: Literal[3],
|
| 62 |
+
IV : Optional[ByteString] = ...,
|
| 63 |
+
segment_size : int = ...,
|
| 64 |
+
use_aesni : bool = ...) -> \
|
| 65 |
+
CfbMode: ...
|
| 66 |
+
|
| 67 |
+
# MODE_OFB
|
| 68 |
+
@overload
|
| 69 |
+
def new(key: ByteString,
|
| 70 |
+
mode: Literal[5],
|
| 71 |
+
iv : Optional[ByteString] = ...,
|
| 72 |
+
use_aesni : bool = ...) -> \
|
| 73 |
+
OfbMode: ...
|
| 74 |
+
|
| 75 |
+
@overload
|
| 76 |
+
def new(key: ByteString,
|
| 77 |
+
mode: Literal[5],
|
| 78 |
+
IV : Optional[ByteString] = ...,
|
| 79 |
+
use_aesni : bool = ...) -> \
|
| 80 |
+
OfbMode: ...
|
| 81 |
+
|
| 82 |
+
# MODE_CTR
|
| 83 |
+
@overload
|
| 84 |
+
def new(key: ByteString,
|
| 85 |
+
mode: Literal[6],
|
| 86 |
+
nonce : Optional[ByteString] = ...,
|
| 87 |
+
initial_value : Union[int, ByteString] = ...,
|
| 88 |
+
counter : Dict = ...,
|
| 89 |
+
use_aesni : bool = ...) -> \
|
| 90 |
+
CtrMode: ...
|
| 91 |
+
|
| 92 |
+
# MODE_OPENPGP
|
| 93 |
+
@overload
|
| 94 |
+
def new(key: ByteString,
|
| 95 |
+
mode: Literal[7],
|
| 96 |
+
iv : Optional[ByteString] = ...,
|
| 97 |
+
use_aesni : bool = ...) -> \
|
| 98 |
+
OpenPgpMode: ...
|
| 99 |
+
|
| 100 |
+
@overload
|
| 101 |
+
def new(key: ByteString,
|
| 102 |
+
mode: Literal[7],
|
| 103 |
+
IV : Optional[ByteString] = ...,
|
| 104 |
+
use_aesni : bool = ...) -> \
|
| 105 |
+
OpenPgpMode: ...
|
| 106 |
+
|
| 107 |
+
# MODE_CCM
|
| 108 |
+
@overload
|
| 109 |
+
def new(key: ByteString,
|
| 110 |
+
mode: Literal[8],
|
| 111 |
+
nonce : Optional[ByteString] = ...,
|
| 112 |
+
mac_len : int = ...,
|
| 113 |
+
assoc_len : int = ...,
|
| 114 |
+
use_aesni : bool = ...) -> \
|
| 115 |
+
CcmMode: ...
|
| 116 |
+
|
| 117 |
+
# MODE_EAX
|
| 118 |
+
@overload
|
| 119 |
+
def new(key: ByteString,
|
| 120 |
+
mode: Literal[9],
|
| 121 |
+
nonce : Optional[ByteString] = ...,
|
| 122 |
+
mac_len : int = ...,
|
| 123 |
+
use_aesni : bool = ...) -> \
|
| 124 |
+
EaxMode: ...
|
| 125 |
+
|
| 126 |
+
# MODE_GCM
|
| 127 |
+
@overload
|
| 128 |
+
def new(key: ByteString,
|
| 129 |
+
mode: Literal[10],
|
| 130 |
+
nonce : Optional[ByteString] = ...,
|
| 131 |
+
use_aesni : bool = ...) -> \
|
| 132 |
+
SivMode: ...
|
| 133 |
+
|
| 134 |
+
# MODE_SIV
|
| 135 |
+
@overload
|
| 136 |
+
def new(key: ByteString,
|
| 137 |
+
mode: Literal[11],
|
| 138 |
+
nonce : Optional[ByteString] = ...,
|
| 139 |
+
mac_len : int = ...,
|
| 140 |
+
use_aesni : bool = ...) -> \
|
| 141 |
+
GcmMode: ...
|
| 142 |
+
|
| 143 |
+
# MODE_OCB
|
| 144 |
+
@overload
|
| 145 |
+
def new(key: ByteString,
|
| 146 |
+
mode: Literal[12],
|
| 147 |
+
nonce : Optional[ByteString] = ...,
|
| 148 |
+
mac_len : int = ...,
|
| 149 |
+
use_aesni : bool = ...) -> \
|
| 150 |
+
OcbMode: ...
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
block_size: int
|
| 154 |
+
key_size: Tuple[int, int, int]
|
venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# Cipher/ARC2.py : ARC2.py
|
| 4 |
+
#
|
| 5 |
+
# ===================================================================
|
| 6 |
+
# The contents of this file are dedicated to the public domain. To
|
| 7 |
+
# the extent that dedication to the public domain is not available,
|
| 8 |
+
# everyone is granted a worldwide, perpetual, royalty-free,
|
| 9 |
+
# non-exclusive license to exercise all rights associated with the
|
| 10 |
+
# contents of this file for any purpose whatsoever.
|
| 11 |
+
# No rights are reserved.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 14 |
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 15 |
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 16 |
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
| 17 |
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
| 18 |
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 19 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 20 |
+
# SOFTWARE.
|
| 21 |
+
# ===================================================================
|
| 22 |
+
"""
|
| 23 |
+
Module's constants for the modes of operation supported with ARC2:
|
| 24 |
+
|
| 25 |
+
:var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
|
| 26 |
+
:var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
|
| 27 |
+
:var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
|
| 28 |
+
:var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
|
| 29 |
+
:var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
|
| 30 |
+
:var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
|
| 31 |
+
:var MODE_EAX: :ref:`EAX Mode <eax_mode>`
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
import sys
|
| 35 |
+
|
| 36 |
+
from Crypto.Cipher import _create_cipher
|
| 37 |
+
from Crypto.Util.py3compat import byte_string
|
| 38 |
+
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
|
| 39 |
+
VoidPointer, SmartPointer,
|
| 40 |
+
c_size_t, c_uint8_ptr)
|
| 41 |
+
|
| 42 |
+
_raw_arc2_lib = load_pycryptodome_raw_lib(
|
| 43 |
+
"Crypto.Cipher._raw_arc2",
|
| 44 |
+
"""
|
| 45 |
+
int ARC2_start_operation(const uint8_t key[],
|
| 46 |
+
size_t key_len,
|
| 47 |
+
size_t effective_key_len,
|
| 48 |
+
void **pResult);
|
| 49 |
+
int ARC2_encrypt(const void *state,
|
| 50 |
+
const uint8_t *in,
|
| 51 |
+
uint8_t *out,
|
| 52 |
+
size_t data_len);
|
| 53 |
+
int ARC2_decrypt(const void *state,
|
| 54 |
+
const uint8_t *in,
|
| 55 |
+
uint8_t *out,
|
| 56 |
+
size_t data_len);
|
| 57 |
+
int ARC2_stop_operation(void *state);
|
| 58 |
+
"""
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def _create_base_cipher(dict_parameters):
|
| 63 |
+
"""This method instantiates and returns a handle to a low-level
|
| 64 |
+
base cipher. It will absorb named parameters in the process."""
|
| 65 |
+
|
| 66 |
+
try:
|
| 67 |
+
key = dict_parameters.pop("key")
|
| 68 |
+
except KeyError:
|
| 69 |
+
raise TypeError("Missing 'key' parameter")
|
| 70 |
+
|
| 71 |
+
effective_keylen = dict_parameters.pop("effective_keylen", 1024)
|
| 72 |
+
|
| 73 |
+
if len(key) not in key_size:
|
| 74 |
+
raise ValueError("Incorrect ARC2 key length (%d bytes)" % len(key))
|
| 75 |
+
|
| 76 |
+
if not (40 <= effective_keylen <= 1024):
|
| 77 |
+
raise ValueError("'effective_key_len' must be at least 40 and no larger than 1024 "
|
| 78 |
+
"(not %d)" % effective_keylen)
|
| 79 |
+
|
| 80 |
+
start_operation = _raw_arc2_lib.ARC2_start_operation
|
| 81 |
+
stop_operation = _raw_arc2_lib.ARC2_stop_operation
|
| 82 |
+
|
| 83 |
+
cipher = VoidPointer()
|
| 84 |
+
result = start_operation(c_uint8_ptr(key),
|
| 85 |
+
c_size_t(len(key)),
|
| 86 |
+
c_size_t(effective_keylen),
|
| 87 |
+
cipher.address_of())
|
| 88 |
+
if result:
|
| 89 |
+
raise ValueError("Error %X while instantiating the ARC2 cipher"
|
| 90 |
+
% result)
|
| 91 |
+
|
| 92 |
+
return SmartPointer(cipher.get(), stop_operation)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def new(key, mode, *args, **kwargs):
|
| 96 |
+
"""Create a new RC2 cipher.
|
| 97 |
+
|
| 98 |
+
:param key:
|
| 99 |
+
The secret key to use in the symmetric cipher.
|
| 100 |
+
Its length can vary from 5 to 128 bytes; the actual search space
|
| 101 |
+
(and the cipher strength) can be reduced with the ``effective_keylen`` parameter.
|
| 102 |
+
:type key: bytes, bytearray, memoryview
|
| 103 |
+
|
| 104 |
+
:param mode:
|
| 105 |
+
The chaining mode to use for encryption or decryption.
|
| 106 |
+
:type mode: One of the supported ``MODE_*`` constants
|
| 107 |
+
|
| 108 |
+
:Keyword Arguments:
|
| 109 |
+
* **iv** (*bytes*, *bytearray*, *memoryview*) --
|
| 110 |
+
(Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
|
| 111 |
+
and ``MODE_OPENPGP`` modes).
|
| 112 |
+
|
| 113 |
+
The initialization vector to use for encryption or decryption.
|
| 114 |
+
|
| 115 |
+
For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
|
| 116 |
+
|
| 117 |
+
For ``MODE_OPENPGP`` mode only,
|
| 118 |
+
it must be 8 bytes long for encryption
|
| 119 |
+
and 10 bytes for decryption (in the latter case, it is
|
| 120 |
+
actually the *encrypted* IV which was prefixed to the ciphertext).
|
| 121 |
+
|
| 122 |
+
If not provided, a random byte string is generated (you must then
|
| 123 |
+
read its value with the :attr:`iv` attribute).
|
| 124 |
+
|
| 125 |
+
* **nonce** (*bytes*, *bytearray*, *memoryview*) --
|
| 126 |
+
(Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
|
| 127 |
+
|
| 128 |
+
A value that must never be reused for any other encryption done
|
| 129 |
+
with this key.
|
| 130 |
+
|
| 131 |
+
For ``MODE_EAX`` there are no
|
| 132 |
+
restrictions on its length (recommended: **16** bytes).
|
| 133 |
+
|
| 134 |
+
For ``MODE_CTR``, its length must be in the range **[0..7]**.
|
| 135 |
+
|
| 136 |
+
If not provided for ``MODE_EAX``, a random byte string is generated (you
|
| 137 |
+
can read it back via the ``nonce`` attribute).
|
| 138 |
+
|
| 139 |
+
* **effective_keylen** (*integer*) --
|
| 140 |
+
Optional. Maximum strength in bits of the actual key used by the ARC2 algorithm.
|
| 141 |
+
If the supplied ``key`` parameter is longer (in bits) of the value specified
|
| 142 |
+
here, it will be weakened to match it.
|
| 143 |
+
If not specified, no limitation is applied.
|
| 144 |
+
|
| 145 |
+
* **segment_size** (*integer*) --
|
| 146 |
+
(Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
|
| 147 |
+
are segmented in. It must be a multiple of 8.
|
| 148 |
+
If not specified, it will be assumed to be 8.
|
| 149 |
+
|
| 150 |
+
* **mac_len** : (*integer*) --
|
| 151 |
+
(Only ``MODE_EAX``)
|
| 152 |
+
Length of the authentication tag, in bytes.
|
| 153 |
+
It must be no longer than 8 (default).
|
| 154 |
+
|
| 155 |
+
* **initial_value** : (*integer*) --
|
| 156 |
+
(Only ``MODE_CTR``). The initial value for the counter within
|
| 157 |
+
the counter block. By default it is **0**.
|
| 158 |
+
|
| 159 |
+
:Return: an ARC2 object, of the applicable mode.
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
|
| 163 |
+
|
| 164 |
+
MODE_ECB = 1
|
| 165 |
+
MODE_CBC = 2
|
| 166 |
+
MODE_CFB = 3
|
| 167 |
+
MODE_OFB = 5
|
| 168 |
+
MODE_CTR = 6
|
| 169 |
+
MODE_OPENPGP = 7
|
| 170 |
+
MODE_EAX = 9
|
| 171 |
+
|
| 172 |
+
# Size of a data block (in bytes)
|
| 173 |
+
block_size = 8
|
| 174 |
+
# Size of a key (in bytes)
|
| 175 |
+
key_size = range(5, 128 + 1)
|
venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Union, Dict, Iterable, Optional, ByteString
|
| 2 |
+
|
| 3 |
+
from Crypto.Cipher._mode_ecb import EcbMode
|
| 4 |
+
from Crypto.Cipher._mode_cbc import CbcMode
|
| 5 |
+
from Crypto.Cipher._mode_cfb import CfbMode
|
| 6 |
+
from Crypto.Cipher._mode_ofb import OfbMode
|
| 7 |
+
from Crypto.Cipher._mode_ctr import CtrMode
|
| 8 |
+
from Crypto.Cipher._mode_openpgp import OpenPgpMode
|
| 9 |
+
from Crypto.Cipher._mode_eax import EaxMode
|
| 10 |
+
|
| 11 |
+
ARC2Mode = int
|
| 12 |
+
|
| 13 |
+
MODE_ECB: ARC2Mode
|
| 14 |
+
MODE_CBC: ARC2Mode
|
| 15 |
+
MODE_CFB: ARC2Mode
|
| 16 |
+
MODE_OFB: ARC2Mode
|
| 17 |
+
MODE_CTR: ARC2Mode
|
| 18 |
+
MODE_OPENPGP: ARC2Mode
|
| 19 |
+
MODE_EAX: ARC2Mode
|
| 20 |
+
|
| 21 |
+
def new(key: ByteString,
|
| 22 |
+
mode: ARC2Mode,
|
| 23 |
+
iv : Optional[ByteString] = ...,
|
| 24 |
+
IV : Optional[ByteString] = ...,
|
| 25 |
+
nonce : Optional[ByteString] = ...,
|
| 26 |
+
segment_size : int = ...,
|
| 27 |
+
mac_len : int = ...,
|
| 28 |
+
initial_value : Union[int, ByteString] = ...,
|
| 29 |
+
counter : Dict = ...) -> \
|
| 30 |
+
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
|
| 31 |
+
|
| 32 |
+
block_size: int
|
| 33 |
+
key_size: Iterable[int]
|
venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# Cipher/ARC4.py : ARC4
|
| 4 |
+
#
|
| 5 |
+
# ===================================================================
|
| 6 |
+
# The contents of this file are dedicated to the public domain. To
|
| 7 |
+
# the extent that dedication to the public domain is not available,
|
| 8 |
+
# everyone is granted a worldwide, perpetual, royalty-free,
|
| 9 |
+
# non-exclusive license to exercise all rights associated with the
|
| 10 |
+
# contents of this file for any purpose whatsoever.
|
| 11 |
+
# No rights are reserved.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 14 |
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 15 |
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 16 |
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
| 17 |
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
| 18 |
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 19 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 20 |
+
# SOFTWARE.
|
| 21 |
+
# ===================================================================
|
| 22 |
+
|
| 23 |
+
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer,
|
| 24 |
+
create_string_buffer, get_raw_buffer,
|
| 25 |
+
SmartPointer, c_size_t, c_uint8_ptr)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
_raw_arc4_lib = load_pycryptodome_raw_lib("Crypto.Cipher._ARC4", """
|
| 29 |
+
int ARC4_stream_encrypt(void *rc4State, const uint8_t in[],
|
| 30 |
+
uint8_t out[], size_t len);
|
| 31 |
+
int ARC4_stream_init(uint8_t *key, size_t keylen,
|
| 32 |
+
void **pRc4State);
|
| 33 |
+
int ARC4_stream_destroy(void *rc4State);
|
| 34 |
+
""")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class ARC4Cipher:
|
| 38 |
+
"""ARC4 cipher object. Do not create it directly. Use
|
| 39 |
+
:func:`Crypto.Cipher.ARC4.new` instead.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(self, key, *args, **kwargs):
|
| 43 |
+
"""Initialize an ARC4 cipher object
|
| 44 |
+
|
| 45 |
+
See also `new()` at the module level."""
|
| 46 |
+
|
| 47 |
+
if len(args) > 0:
|
| 48 |
+
ndrop = args[0]
|
| 49 |
+
args = args[1:]
|
| 50 |
+
else:
|
| 51 |
+
ndrop = kwargs.pop('drop', 0)
|
| 52 |
+
|
| 53 |
+
if len(key) not in key_size:
|
| 54 |
+
raise ValueError("Incorrect ARC4 key length (%d bytes)" %
|
| 55 |
+
len(key))
|
| 56 |
+
|
| 57 |
+
self._state = VoidPointer()
|
| 58 |
+
result = _raw_arc4_lib.ARC4_stream_init(c_uint8_ptr(key),
|
| 59 |
+
c_size_t(len(key)),
|
| 60 |
+
self._state.address_of())
|
| 61 |
+
if result != 0:
|
| 62 |
+
raise ValueError("Error %d while creating the ARC4 cipher"
|
| 63 |
+
% result)
|
| 64 |
+
self._state = SmartPointer(self._state.get(),
|
| 65 |
+
_raw_arc4_lib.ARC4_stream_destroy)
|
| 66 |
+
|
| 67 |
+
if ndrop > 0:
|
| 68 |
+
# This is OK even if the cipher is used for decryption,
|
| 69 |
+
# since encrypt and decrypt are actually the same thing
|
| 70 |
+
# with ARC4.
|
| 71 |
+
self.encrypt(b'\x00' * ndrop)
|
| 72 |
+
|
| 73 |
+
self.block_size = 1
|
| 74 |
+
self.key_size = len(key)
|
| 75 |
+
|
| 76 |
+
def encrypt(self, plaintext):
|
| 77 |
+
"""Encrypt a piece of data.
|
| 78 |
+
|
| 79 |
+
:param plaintext: The data to encrypt, of any size.
|
| 80 |
+
:type plaintext: bytes, bytearray, memoryview
|
| 81 |
+
:returns: the encrypted byte string, of equal length as the
|
| 82 |
+
plaintext.
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
ciphertext = create_string_buffer(len(plaintext))
|
| 86 |
+
result = _raw_arc4_lib.ARC4_stream_encrypt(self._state.get(),
|
| 87 |
+
c_uint8_ptr(plaintext),
|
| 88 |
+
ciphertext,
|
| 89 |
+
c_size_t(len(plaintext)))
|
| 90 |
+
if result:
|
| 91 |
+
raise ValueError("Error %d while encrypting with RC4" % result)
|
| 92 |
+
return get_raw_buffer(ciphertext)
|
| 93 |
+
|
| 94 |
+
def decrypt(self, ciphertext):
|
| 95 |
+
"""Decrypt a piece of data.
|
| 96 |
+
|
| 97 |
+
:param ciphertext: The data to decrypt, of any size.
|
| 98 |
+
:type ciphertext: bytes, bytearray, memoryview
|
| 99 |
+
:returns: the decrypted byte string, of equal length as the
|
| 100 |
+
ciphertext.
|
| 101 |
+
"""
|
| 102 |
+
|
| 103 |
+
try:
|
| 104 |
+
return self.encrypt(ciphertext)
|
| 105 |
+
except ValueError as e:
|
| 106 |
+
raise ValueError(str(e).replace("enc", "dec"))
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def new(key, *args, **kwargs):
|
| 110 |
+
"""Create a new ARC4 cipher.
|
| 111 |
+
|
| 112 |
+
:param key:
|
| 113 |
+
The secret key to use in the symmetric cipher.
|
| 114 |
+
Its length must be in the range ``[1..256]``.
|
| 115 |
+
The recommended length is 16 bytes.
|
| 116 |
+
:type key: bytes, bytearray, memoryview
|
| 117 |
+
|
| 118 |
+
:Keyword Arguments:
|
| 119 |
+
* *drop* (``integer``) --
|
| 120 |
+
The amount of bytes to discard from the initial part of the keystream.
|
| 121 |
+
In fact, such part has been found to be distinguishable from random
|
| 122 |
+
data (while it shouldn't) and also correlated to key.
|
| 123 |
+
|
| 124 |
+
The recommended value is 3072_ bytes. The default value is 0.
|
| 125 |
+
|
| 126 |
+
:Return: an `ARC4Cipher` object
|
| 127 |
+
|
| 128 |
+
.. _3072: http://eprint.iacr.org/2002/067.pdf
|
| 129 |
+
"""
|
| 130 |
+
return ARC4Cipher(key, *args, **kwargs)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
# Size of a data block (in bytes)
|
| 134 |
+
block_size = 1
|
| 135 |
+
# Size of a key (in bytes)
|
| 136 |
+
key_size = range(1, 256+1)
|
venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.pyi
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Union, Iterable, ByteString
|
| 2 |
+
|
| 3 |
+
class ARC4Cipher:
|
| 4 |
+
block_size: int
|
| 5 |
+
key_size: int
|
| 6 |
+
|
| 7 |
+
def __init__(self, key: ByteString, *args: Any, **kwargs: Any) -> None: ...
|
| 8 |
+
def encrypt(self, plaintext: ByteString) -> bytes: ...
|
| 9 |
+
def decrypt(self, ciphertext: ByteString) -> bytes: ...
|
| 10 |
+
|
| 11 |
+
def new(key: ByteString, drop : int = ...) -> ARC4Cipher: ...
|
| 12 |
+
|
| 13 |
+
block_size: int
|
| 14 |
+
key_size: Iterable[int]
|
venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# Cipher/Blowfish.py : Blowfish
|
| 4 |
+
#
|
| 5 |
+
# ===================================================================
|
| 6 |
+
# The contents of this file are dedicated to the public domain. To
|
| 7 |
+
# the extent that dedication to the public domain is not available,
|
| 8 |
+
# everyone is granted a worldwide, perpetual, royalty-free,
|
| 9 |
+
# non-exclusive license to exercise all rights associated with the
|
| 10 |
+
# contents of this file for any purpose whatsoever.
|
| 11 |
+
# No rights are reserved.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 14 |
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 15 |
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 16 |
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
| 17 |
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
| 18 |
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 19 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 20 |
+
# SOFTWARE.
|
| 21 |
+
# ===================================================================
|
| 22 |
+
"""
|
| 23 |
+
Module's constants for the modes of operation supported with Blowfish:
|
| 24 |
+
|
| 25 |
+
:var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
|
| 26 |
+
:var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
|
| 27 |
+
:var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
|
| 28 |
+
:var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
|
| 29 |
+
:var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
|
| 30 |
+
:var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
|
| 31 |
+
:var MODE_EAX: :ref:`EAX Mode <eax_mode>`
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
import sys
|
| 35 |
+
|
| 36 |
+
from Crypto.Cipher import _create_cipher
|
| 37 |
+
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
|
| 38 |
+
VoidPointer, SmartPointer, c_size_t,
|
| 39 |
+
c_uint8_ptr)
|
| 40 |
+
|
| 41 |
+
_raw_blowfish_lib = load_pycryptodome_raw_lib(
|
| 42 |
+
"Crypto.Cipher._raw_blowfish",
|
| 43 |
+
"""
|
| 44 |
+
int Blowfish_start_operation(const uint8_t key[],
|
| 45 |
+
size_t key_len,
|
| 46 |
+
void **pResult);
|
| 47 |
+
int Blowfish_encrypt(const void *state,
|
| 48 |
+
const uint8_t *in,
|
| 49 |
+
uint8_t *out,
|
| 50 |
+
size_t data_len);
|
| 51 |
+
int Blowfish_decrypt(const void *state,
|
| 52 |
+
const uint8_t *in,
|
| 53 |
+
uint8_t *out,
|
| 54 |
+
size_t data_len);
|
| 55 |
+
int Blowfish_stop_operation(void *state);
|
| 56 |
+
"""
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _create_base_cipher(dict_parameters):
|
| 61 |
+
"""This method instantiates and returns a smart pointer to
|
| 62 |
+
a low-level base cipher. It will absorb named parameters in
|
| 63 |
+
the process."""
|
| 64 |
+
|
| 65 |
+
try:
|
| 66 |
+
key = dict_parameters.pop("key")
|
| 67 |
+
except KeyError:
|
| 68 |
+
raise TypeError("Missing 'key' parameter")
|
| 69 |
+
|
| 70 |
+
if len(key) not in key_size:
|
| 71 |
+
raise ValueError("Incorrect Blowfish key length (%d bytes)" % len(key))
|
| 72 |
+
|
| 73 |
+
start_operation = _raw_blowfish_lib.Blowfish_start_operation
|
| 74 |
+
stop_operation = _raw_blowfish_lib.Blowfish_stop_operation
|
| 75 |
+
|
| 76 |
+
void_p = VoidPointer()
|
| 77 |
+
result = start_operation(c_uint8_ptr(key),
|
| 78 |
+
c_size_t(len(key)),
|
| 79 |
+
void_p.address_of())
|
| 80 |
+
if result:
|
| 81 |
+
raise ValueError("Error %X while instantiating the Blowfish cipher"
|
| 82 |
+
% result)
|
| 83 |
+
return SmartPointer(void_p.get(), stop_operation)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def new(key, mode, *args, **kwargs):
|
| 87 |
+
"""Create a new Blowfish cipher
|
| 88 |
+
|
| 89 |
+
:param key:
|
| 90 |
+
The secret key to use in the symmetric cipher.
|
| 91 |
+
Its length can vary from 5 to 56 bytes.
|
| 92 |
+
:type key: bytes, bytearray, memoryview
|
| 93 |
+
|
| 94 |
+
:param mode:
|
| 95 |
+
The chaining mode to use for encryption or decryption.
|
| 96 |
+
:type mode: One of the supported ``MODE_*`` constants
|
| 97 |
+
|
| 98 |
+
:Keyword Arguments:
|
| 99 |
+
* **iv** (*bytes*, *bytearray*, *memoryview*) --
|
| 100 |
+
(Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
|
| 101 |
+
and ``MODE_OPENPGP`` modes).
|
| 102 |
+
|
| 103 |
+
The initialization vector to use for encryption or decryption.
|
| 104 |
+
|
| 105 |
+
For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
|
| 106 |
+
|
| 107 |
+
For ``MODE_OPENPGP`` mode only,
|
| 108 |
+
it must be 8 bytes long for encryption
|
| 109 |
+
and 10 bytes for decryption (in the latter case, it is
|
| 110 |
+
actually the *encrypted* IV which was prefixed to the ciphertext).
|
| 111 |
+
|
| 112 |
+
If not provided, a random byte string is generated (you must then
|
| 113 |
+
read its value with the :attr:`iv` attribute).
|
| 114 |
+
|
| 115 |
+
* **nonce** (*bytes*, *bytearray*, *memoryview*) --
|
| 116 |
+
(Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
|
| 117 |
+
|
| 118 |
+
A value that must never be reused for any other encryption done
|
| 119 |
+
with this key.
|
| 120 |
+
|
| 121 |
+
For ``MODE_EAX`` there are no
|
| 122 |
+
restrictions on its length (recommended: **16** bytes).
|
| 123 |
+
|
| 124 |
+
For ``MODE_CTR``, its length must be in the range **[0..7]**.
|
| 125 |
+
|
| 126 |
+
If not provided for ``MODE_EAX``, a random byte string is generated (you
|
| 127 |
+
can read it back via the ``nonce`` attribute).
|
| 128 |
+
|
| 129 |
+
* **segment_size** (*integer*) --
|
| 130 |
+
(Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
|
| 131 |
+
are segmented in. It must be a multiple of 8.
|
| 132 |
+
If not specified, it will be assumed to be 8.
|
| 133 |
+
|
| 134 |
+
* **mac_len** : (*integer*) --
|
| 135 |
+
(Only ``MODE_EAX``)
|
| 136 |
+
Length of the authentication tag, in bytes.
|
| 137 |
+
It must be no longer than 8 (default).
|
| 138 |
+
|
| 139 |
+
* **initial_value** : (*integer*) --
|
| 140 |
+
(Only ``MODE_CTR``). The initial value for the counter within
|
| 141 |
+
the counter block. By default it is **0**.
|
| 142 |
+
|
| 143 |
+
:Return: a Blowfish object, of the applicable mode.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
|
| 147 |
+
|
| 148 |
+
MODE_ECB = 1
|
| 149 |
+
MODE_CBC = 2
|
| 150 |
+
MODE_CFB = 3
|
| 151 |
+
MODE_OFB = 5
|
| 152 |
+
MODE_CTR = 6
|
| 153 |
+
MODE_OPENPGP = 7
|
| 154 |
+
MODE_EAX = 9
|
| 155 |
+
|
| 156 |
+
# Size of a data block (in bytes)
|
| 157 |
+
block_size = 8
|
| 158 |
+
# Size of a key (in bytes)
|
| 159 |
+
key_size = range(4, 56 + 1)
|
venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Union, Dict, Iterable, ByteString, Optional
|
| 2 |
+
|
| 3 |
+
from Crypto.Cipher._mode_ecb import EcbMode
|
| 4 |
+
from Crypto.Cipher._mode_cbc import CbcMode
|
| 5 |
+
from Crypto.Cipher._mode_cfb import CfbMode
|
| 6 |
+
from Crypto.Cipher._mode_ofb import OfbMode
|
| 7 |
+
from Crypto.Cipher._mode_ctr import CtrMode
|
| 8 |
+
from Crypto.Cipher._mode_openpgp import OpenPgpMode
|
| 9 |
+
from Crypto.Cipher._mode_eax import EaxMode
|
| 10 |
+
|
| 11 |
+
BlowfishMode = int
|
| 12 |
+
|
| 13 |
+
MODE_ECB: BlowfishMode
|
| 14 |
+
MODE_CBC: BlowfishMode
|
| 15 |
+
MODE_CFB: BlowfishMode
|
| 16 |
+
MODE_OFB: BlowfishMode
|
| 17 |
+
MODE_CTR: BlowfishMode
|
| 18 |
+
MODE_OPENPGP: BlowfishMode
|
| 19 |
+
MODE_EAX: BlowfishMode
|
| 20 |
+
|
| 21 |
+
def new(key: ByteString,
|
| 22 |
+
mode: BlowfishMode,
|
| 23 |
+
iv : Optional[ByteString] = ...,
|
| 24 |
+
IV : Optional[ByteString] = ...,
|
| 25 |
+
nonce : Optional[ByteString] = ...,
|
| 26 |
+
segment_size : int = ...,
|
| 27 |
+
mac_len : int = ...,
|
| 28 |
+
initial_value : Union[int, ByteString] = ...,
|
| 29 |
+
counter : Dict = ...) -> \
|
| 30 |
+
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
|
| 31 |
+
|
| 32 |
+
block_size: int
|
| 33 |
+
key_size: Iterable[int]
|
venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# Cipher/CAST.py : CAST
|
| 4 |
+
#
|
| 5 |
+
# ===================================================================
|
| 6 |
+
# The contents of this file are dedicated to the public domain. To
|
| 7 |
+
# the extent that dedication to the public domain is not available,
|
| 8 |
+
# everyone is granted a worldwide, perpetual, royalty-free,
|
| 9 |
+
# non-exclusive license to exercise all rights associated with the
|
| 10 |
+
# contents of this file for any purpose whatsoever.
|
| 11 |
+
# No rights are reserved.
|
| 12 |
+
#
|
| 13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 14 |
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 15 |
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 16 |
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
| 17 |
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
| 18 |
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 19 |
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 20 |
+
# SOFTWARE.
|
| 21 |
+
# ===================================================================
|
| 22 |
+
"""
|
| 23 |
+
Module's constants for the modes of operation supported with CAST:
|
| 24 |
+
|
| 25 |
+
:var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
|
| 26 |
+
:var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
|
| 27 |
+
:var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
|
| 28 |
+
:var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
|
| 29 |
+
:var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
|
| 30 |
+
:var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
|
| 31 |
+
:var MODE_EAX: :ref:`EAX Mode <eax_mode>`
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
import sys
|
| 35 |
+
|
| 36 |
+
from Crypto.Cipher import _create_cipher
|
| 37 |
+
from Crypto.Util.py3compat import byte_string
|
| 38 |
+
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
|
| 39 |
+
VoidPointer, SmartPointer,
|
| 40 |
+
c_size_t, c_uint8_ptr)
|
| 41 |
+
|
| 42 |
+
_raw_cast_lib = load_pycryptodome_raw_lib(
|
| 43 |
+
"Crypto.Cipher._raw_cast",
|
| 44 |
+
"""
|
| 45 |
+
int CAST_start_operation(const uint8_t key[],
|
| 46 |
+
size_t key_len,
|
| 47 |
+
void **pResult);
|
| 48 |
+
int CAST_encrypt(const void *state,
|
| 49 |
+
const uint8_t *in,
|
| 50 |
+
uint8_t *out,
|
| 51 |
+
size_t data_len);
|
| 52 |
+
int CAST_decrypt(const void *state,
|
| 53 |
+
const uint8_t *in,
|
| 54 |
+
uint8_t *out,
|
| 55 |
+
size_t data_len);
|
| 56 |
+
int CAST_stop_operation(void *state);
|
| 57 |
+
""")
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _create_base_cipher(dict_parameters):
|
| 61 |
+
"""This method instantiates and returns a handle to a low-level
|
| 62 |
+
base cipher. It will absorb named parameters in the process."""
|
| 63 |
+
|
| 64 |
+
try:
|
| 65 |
+
key = dict_parameters.pop("key")
|
| 66 |
+
except KeyError:
|
| 67 |
+
raise TypeError("Missing 'key' parameter")
|
| 68 |
+
|
| 69 |
+
if len(key) not in key_size:
|
| 70 |
+
raise ValueError("Incorrect CAST key length (%d bytes)" % len(key))
|
| 71 |
+
|
| 72 |
+
start_operation = _raw_cast_lib.CAST_start_operation
|
| 73 |
+
stop_operation = _raw_cast_lib.CAST_stop_operation
|
| 74 |
+
|
| 75 |
+
cipher = VoidPointer()
|
| 76 |
+
result = start_operation(c_uint8_ptr(key),
|
| 77 |
+
c_size_t(len(key)),
|
| 78 |
+
cipher.address_of())
|
| 79 |
+
if result:
|
| 80 |
+
raise ValueError("Error %X while instantiating the CAST cipher"
|
| 81 |
+
% result)
|
| 82 |
+
|
| 83 |
+
return SmartPointer(cipher.get(), stop_operation)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def new(key, mode, *args, **kwargs):
|
| 87 |
+
"""Create a new CAST cipher
|
| 88 |
+
|
| 89 |
+
:param key:
|
| 90 |
+
The secret key to use in the symmetric cipher.
|
| 91 |
+
Its length can vary from 5 to 16 bytes.
|
| 92 |
+
:type key: bytes, bytearray, memoryview
|
| 93 |
+
|
| 94 |
+
:param mode:
|
| 95 |
+
The chaining mode to use for encryption or decryption.
|
| 96 |
+
:type mode: One of the supported ``MODE_*`` constants
|
| 97 |
+
|
| 98 |
+
:Keyword Arguments:
|
| 99 |
+
* **iv** (*bytes*, *bytearray*, *memoryview*) --
|
| 100 |
+
(Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
|
| 101 |
+
and ``MODE_OPENPGP`` modes).
|
| 102 |
+
|
| 103 |
+
The initialization vector to use for encryption or decryption.
|
| 104 |
+
|
| 105 |
+
For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
|
| 106 |
+
|
| 107 |
+
For ``MODE_OPENPGP`` mode only,
|
| 108 |
+
it must be 8 bytes long for encryption
|
| 109 |
+
and 10 bytes for decryption (in the latter case, it is
|
| 110 |
+
actually the *encrypted* IV which was prefixed to the ciphertext).
|
| 111 |
+
|
| 112 |
+
If not provided, a random byte string is generated (you must then
|
| 113 |
+
read its value with the :attr:`iv` attribute).
|
| 114 |
+
|
| 115 |
+
* **nonce** (*bytes*, *bytearray*, *memoryview*) --
|
| 116 |
+
(Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
|
| 117 |
+
|
| 118 |
+
A value that must never be reused for any other encryption done
|
| 119 |
+
with this key.
|
| 120 |
+
|
| 121 |
+
For ``MODE_EAX`` there are no
|
| 122 |
+
restrictions on its length (recommended: **16** bytes).
|
| 123 |
+
|
| 124 |
+
For ``MODE_CTR``, its length must be in the range **[0..7]**.
|
| 125 |
+
|
| 126 |
+
If not provided for ``MODE_EAX``, a random byte string is generated (you
|
| 127 |
+
can read it back via the ``nonce`` attribute).
|
| 128 |
+
|
| 129 |
+
* **segment_size** (*integer*) --
|
| 130 |
+
(Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
|
| 131 |
+
are segmented in. It must be a multiple of 8.
|
| 132 |
+
If not specified, it will be assumed to be 8.
|
| 133 |
+
|
| 134 |
+
* **mac_len** : (*integer*) --
|
| 135 |
+
(Only ``MODE_EAX``)
|
| 136 |
+
Length of the authentication tag, in bytes.
|
| 137 |
+
It must be no longer than 8 (default).
|
| 138 |
+
|
| 139 |
+
* **initial_value** : (*integer*) --
|
| 140 |
+
(Only ``MODE_CTR``). The initial value for the counter within
|
| 141 |
+
the counter block. By default it is **0**.
|
| 142 |
+
|
| 143 |
+
:Return: a CAST object, of the applicable mode.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
|
| 147 |
+
|
| 148 |
+
MODE_ECB = 1
|
| 149 |
+
MODE_CBC = 2
|
| 150 |
+
MODE_CFB = 3
|
| 151 |
+
MODE_OFB = 5
|
| 152 |
+
MODE_CTR = 6
|
| 153 |
+
MODE_OPENPGP = 7
|
| 154 |
+
MODE_EAX = 9
|
| 155 |
+
|
| 156 |
+
# Size of a data block (in bytes)
|
| 157 |
+
block_size = 8
|
| 158 |
+
# Size of a key (in bytes)
|
| 159 |
+
key_size = range(5, 16 + 1)
|
venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Union, Dict, Iterable, Optional, ByteString
|
| 2 |
+
|
| 3 |
+
from Crypto.Cipher._mode_ecb import EcbMode
|
| 4 |
+
from Crypto.Cipher._mode_cbc import CbcMode
|
| 5 |
+
from Crypto.Cipher._mode_cfb import CfbMode
|
| 6 |
+
from Crypto.Cipher._mode_ofb import OfbMode
|
| 7 |
+
from Crypto.Cipher._mode_ctr import CtrMode
|
| 8 |
+
from Crypto.Cipher._mode_openpgp import OpenPgpMode
|
| 9 |
+
from Crypto.Cipher._mode_eax import EaxMode
|
| 10 |
+
|
| 11 |
+
CASTMode = int
|
| 12 |
+
|
| 13 |
+
MODE_ECB: CASTMode
|
| 14 |
+
MODE_CBC: CASTMode
|
| 15 |
+
MODE_CFB: CASTMode
|
| 16 |
+
MODE_OFB: CASTMode
|
| 17 |
+
MODE_CTR: CASTMode
|
| 18 |
+
MODE_OPENPGP: CASTMode
|
| 19 |
+
MODE_EAX: CASTMode
|
| 20 |
+
|
| 21 |
+
def new(key: ByteString,
|
| 22 |
+
mode: CASTMode,
|
| 23 |
+
iv : Optional[ByteString] = ...,
|
| 24 |
+
IV : Optional[ByteString] = ...,
|
| 25 |
+
nonce : Optional[ByteString] = ...,
|
| 26 |
+
segment_size : int = ...,
|
| 27 |
+
mac_len : int = ...,
|
| 28 |
+
initial_value : Union[int, ByteString] = ...,
|
| 29 |
+
counter : Dict = ...) -> \
|
| 30 |
+
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
|
| 31 |
+
|
| 32 |
+
block_size: int
|
| 33 |
+
key_size : Iterable[int]
|