MCPcopy Create free account
hub / github.com/archlinux/archinstall / encrypt

Function encrypt

archinstall/lib/crypt.py:100–108  ·  view source on GitHub ↗
(password: str, data: str)

Source from the content-addressed store, hash-verified

98
99
100def encrypt(password: str, data: str) -> str:
101 salt = os.urandom(16)
102 f = _get_fernet(salt, password)
103 token = f.encrypt(data.encode('utf-8'))
104
105 encoded_token = base64.urlsafe_b64encode(token).decode('utf-8')
106 encoded_salt = base64.urlsafe_b64encode(salt).decode('utf-8')
107
108 return f'$argon2id${encoded_salt}${encoded_token}'
109
110
111def decrypt(data: str, password: str) -> str:

Callers 1

save_user_credsMethod · 0.90

Calls 3

_get_fernetFunction · 0.85
encryptMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected