Pseudonymization with keyed-hash function in Python and AWS

Ruslan Korniichuk
Apr 18 · 3 min read

Table of Contents

Step 1: AWS KMS

Step 2: AWS Secrets Manager

Step 3: Python

import hashlib
import json
import boto3
email = ''
secretsmanager = boto3.client('secretsmanager')
response = secretsmanager.get_secret_value(SecretId='Medium')
secret_string = response['SecretString']
hash_key = json.loads(secret_string)['hash_key']
sha3 = hashlib.sha3_512()
data = email + hash_key
digest = sha3.hexdigest()

Ruslan Korniichuk

Written by

Python Developer and AI Engineer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade