英文:
alter email address in DB to render it un-deliverable
问题
I need to alter email addresses of users to render them undeliverable (not ever a real address), however it needs to be reversible so that the original is visible or at least retrievable (without storing it elsewhere).
For example john@example.com -> NONAME_john@exampleNOTHING.com
might work as it can be changed back.
However, the problem is that I cannot KNOW that the above-resulting address is not a real email address. Maybe there is a real address out there called NONAME_john@exampleNOTHING.com.
The requirements are that the address needs to be valid (in terms of having '@' and '.com' etc) but won't send.
Maybe my requirements are a contradiction and hence not possible? Does anyone know?
英文:
I need to alter email addresses of users to render them undeliverable (not ever a real address), however it needs to be reversible so that the original is visible or at least retrievable (without storing it elsewhere).
For example john@example.com -> NONAME_john@exampleNOTHING.com
might work as it can be changed back.
However, the problem is that I cannot KNOW that the above-resulting address is not a real email address. Maybe there is a real address out there called NONAME_john@exampleNOTHING.com.
The requirements are that the address needs to be valid (in terms of having '@' and '.com' etc) but won't send.
Maybe my requirements are a contradiction and hence not possible? Does anyone know?
答案1
得分: 1
您的要求有点矛盾。使地址无法工作的唯一方法是使其实际上无效。
请注意,“无效”可以表示至少三种情况:
- 它无法解析为电子邮件地址(例如,将@替换为ⓐ)
- 用户名在该域中无效
- 域名无效
重点是,对于2和3,很难确定是否属于这种情况。
您还可以采取的另一种方法是通过应用可逆转换来混淆电子邮件地址,比如对其进行base64编码。这属于上述第1类。
例如,在Python 3中:
import base64
base64.b64encode('john@example.com'.encode('utf-8'))
# 输出: b'am9obkBleGFtcGxlLmNvbQ=='
base64.b64decode(b'am9obkBleGFtcGxlLmNvbQ==').decode('utf-8')
# 输出: 'john@example.com'
英文:
Your requirements are kind of a contradiction. The only way to make an addres unworkable is to render it practically invalid.
Note that "invalid" can mean at least three things;
- it doesn't parse as an e-mail address (e.g. replace @ by ⓐ)
- the user name is invalid at that domain
- the domain name is invalid
The point is that for 2 and 3 there is no easy way to know for sure if that is the case.
What you also could do is obfuscate the e-mail addres by applying a reversable transformation, like e.g. base64 encoding it. This falls under category 1 above.
For example in Python 3:
In [1]: import base64
In [2]: base64.b64encode('john@example.com'.encode('utf-8'))
Out[2]: b'am9obkBleGFtcGxlLmNvbQ=='
In [3]: base64.b64decode(b'am9obkBleGFtcGxlLmNvbQ==').decode('utf-8')
Out[3]: 'john@example.com'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论