-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor cape key/encrypt to accept username parameter (#111)
* refactor cape key/encrypt to accept username parameter * add user_encrypt example * keyword-only args to cape.key and cape.encrypt * lint
- Loading branch information
Showing
6 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"function_id":"8kpZeYKDQYZEfcXt5SHKjP","function_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjU1NDQ0NDQyMDQsImlhdCI6MTY2ODYyNDE4NCwiaXNzIjoiZ2l0aHVifDgwMDEwMTYiLCJzY29wZSI6ImZ1bmN0aW9uOmludm9rZSIsInN1YiI6IjhrcFplWUtEUVlaRWZjWHQ1U0hLalAifQ.r9pdo1z1-IsszN5F4fqz8TNcKbSCviBFRqhIB0zlIrAwjBKwMt8lkVIV98zcTe4rEJ7aEqyfiV3sSw7yi4RHuVzYCMasaVaGEMxBk_P5aBP7IxByyexngC5RGrYvVzlvjtOi9VIJSZvHr5IUJL06FKZR1gJMsVoRYlOQCMh8W-TCsBDJuwa7c5AshOFtuxu4HTxq-N2AR_CY-BUfHtuarXDJ0o4xRGXnGeTu37IX_PhHWeYIz68SJRqwWLrL5jxUn1Nr-JfUNWH3pN7EOdSTXKpe0qnWqiJaQTorRB36JVjwZdyeJ2y9NjWDxPUjd3efSKATz6d34xFw-JX4h1VyOA","function_checksum":"f654a25ddf65ed79bfe514178126d97e1141857edf10b781c2f8c11525163c88"} | ||
{"function_id":"ji3BJGBgnKDKoC9NvfCtE9","function_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDY4ODkzMTcsImlhdCI6MTY3NTM1MzMxNywiaXNzIjoiZ2l0aHVifDExNDY5NjYyMiIsInNjb3BlIjoiZnVuY3Rpb246aW52b2tlIiwic3ViIjoiamkzQkpHQmduS0RLb0M5TnZmQ3RFOSJ9.lr5QpJINij90pIT_nnv9Gpjk2jMrlxQhZpqg4pkMBYgZNAaJXz_sAD4ubR5Dav7jXUJWYx03hFBI8deB45GrIWTovG2kGLF5JdREXs1XY-F7YPvSxrICMSSleYWi3V1XIwOU8I5nzgp2NhpsrqO6FqsETyBqWOVP4EOogjAdas4rcp2IJE4qDQzNz7HLVLTZuNdVtcXz4YKMiK8n7VpNJkRX5MvAjqjAQ-HGLvpteybCXpK9IZYt3VF3Ge-I3Xw0b7OYa2WuCnfnh3coXnFtfWQEpaoLO5Q6kKkzCCNPtkYgoxNwsn5SxWJiY9KFWBI7ht7Kp-PYmoZAr_2iTOKmZw","function_checksum":"f654a25ddf65ed79bfe514178126d97e1141857edf10b781c2f8c11525163c88"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pathlib | ||
|
||
import pycape | ||
|
||
function_json = pathlib.Path(__file__).parent.absolute() / "echo_token.json" | ||
function_ref = pycape.FunctionRef.from_json(function_json) | ||
|
||
cape = pycape.Cape() | ||
|
||
# Two options to encrypt for a Cape user | ||
|
||
# 1 - retrieve the user's key with cape.key, and pass the key to cape.encrypt | ||
capedocs_key = cape.key(username="capedocs") | ||
encrypted_data = cape.encrypt(b"encrypt against capedocs's key", key=capedocs_key) | ||
result = cape.run(function_ref, encrypted_data) | ||
print(result.decode()) | ||
|
||
# 2 - pass username directly to cape.encrypt | ||
encrypted_data = cape.encrypt( | ||
b"quickly encrypt my data for capedocs", username="capedocs" | ||
) | ||
result = cape.run(function_ref, encrypted_data) | ||
print(result.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters