修改数据库中的电子邮件地址以使其无法送达。

huangapple go评论86阅读模式
英文:

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

您的要求有点矛盾。使地址无法工作的唯一方法是使其实际上无效。

请注意,“无效”可以表示至少三种情况:

  1. 它无法解析为电子邮件地址(例如,将@替换为ⓐ)
  2. 用户名在该域中无效
  3. 域名无效

重点是,对于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;

  1. it doesn't parse as an e-mail address (e.g. replace @ by ⓐ)
  2. the user name is invalid at that domain
  3. 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'

huangapple
  • 本文由 发表于 2020年1月3日 17:28:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/59576009.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定