Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rwm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radoslav Bodó
rwm
Commits
7980bc68
Commit
7980bc68
authored
1 year ago
by
Radoslav Bodó
Browse files
Options
Downloads
Patches
Plain Diff
rclone crypt: refactor obscure to use cryptography package
parent
12b2f025
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+8
-1
8 additions, 1 deletion
Makefile
requirements.txt
+1
-1
1 addition, 1 deletion
requirements.txt
rwm.py
+7
-5
7 additions, 5 deletions
rwm.py
with
16 additions
and
7 deletions
Makefile
+
8
−
1
View file @
7980bc68
all
:
lint
install
:
apt-get
-y
install
awscli make rclone yamllint
apt-get
-y
install
awscli make
python3-cryptography
rclone yamllint
venv
:
apt-get
-y
install
python3-venv
...
...
@@ -9,6 +9,13 @@ venv:
venv/bin/pip
install
-U
pip
venv/bin/pip
install
-r
requirements.lock
venv-refresh
:
apt-get
-y
install
python3-venv
rm
-r
venv
python3
-m
venv venv
venv/bin/pip
install
-U
pip
venv/bin/pip
install
-r
requirements.txt
freeze
:
@
pip freeze |
grep
-v
'^pkg[-_]resources='
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
1
View file @
7980bc68
# runtime
py
crypto
dome
crypto
graphy
# dev
flake8
...
...
This diff is collapsed.
Click to expand it.
rwm.py
+
7
−
5
View file @
7980bc68
...
...
@@ -10,8 +10,8 @@ from pathlib import Path
from
subprocess
import
run
as
subrun
import
yaml
from
C
rypto
.C
ipher
import
AES
from
C
rypto
.Random
import
get_random_bytes
from
c
rypto
graphy.hazmat.primitives.c
ipher
s
import
Cipher
,
algorithms
,
modes
from
c
rypto
graphy.hazmat.backends
import
default_backend
def
is_sublist
(
needle
,
haystack
):
...
...
@@ -36,11 +36,13 @@ def rclone_obscure_password(plaintext, iv=None):
# https://github.com/rclone/rclone/blob/master/fs/config/obscure/obscure.go
# https://github.com/maaaaz/rclonedeobscure
# GTP translate to python cryptography
secret_key
=
b
"
\x9c\x93\x5b\x48\x73\x0a\x55\x4d\x6b\xfd\x7c\x63\xc8\x86\xa9\x2b\xd3\x90\x19\x8e\xb8\x12\x8a\xfb\xf4\xde\x16\x2b\x8b\x95\xf6\x38
"
if
not
iv
:
iv
=
get_
random
_bytes
(
AES
.
block_size
)
cipher
=
AES
.
new
(
key
=
secret_key
,
mode
=
AES
.
MODE_CTR
,
initial_value
=
iv
,
nonce
=
b
''
)
data
=
iv
+
cipher
.
encrypt
(
plaintext
.
encode
())
iv
=
os
.
u
random
(
16
)
encryptor
=
Cipher
(
algorithms
.
AES
(
secret_key
)
,
mode
s
.
CTR
(
iv
),
backend
=
default_backend
()).
encryptor
(
)
data
=
iv
+
encrypt
or
.
update
(
plaintext
.
encode
())
+
encryptor
.
finalize
()
return
base64
.
urlsafe_b64encode
(
data
).
decode
().
rstrip
(
"
=
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment