Alberti或Caesar Cipher在Varchar Field上的SQL中掩盖了数字
我使用了SAS中的Alberti密码来掩盖数字,该数字在不同的长度方面效果很好。但是,我在Redshift SQL中执行相同的任务遇到了麻烦。
如果我有一个相同长度的数字,我可以简单地使用子字符串的组合并拆开并摘取蒙面的数字。如果我的col1
是123456789
,那将是:
substring(col1,9,1)||substring(col1,2,2)||substring(acct_num_full,3,1)||...
但是,我要掩盖的列可以在5-40个字符的任何位置,因此上面的示例将不起作用。我已经尝试了lpad
和rpad
标准化长度,但对于较短的数字不起作用。
有没有人有任何想法,或者在不同角色列中在SQL中曾在SQL中做过Alberti或Caesar Cipher?我需要一种也可以逆转的算法,以便我可以解密。
I've used an Alberti cipher in SAS to mask numbers which works great on varying lengths. However, I'm having trouble doing the same task in Redshift SQL.
If I have a number all the same length, I could simply use a combination of substrings and to pick apart and Frankenstein a masked number. If my COL1
is 123456789
, it would be something like:
substring(col1,9,1)||substring(col1,2,2)||substring(acct_num_full,3,1)||...
However, the column I'm trying to mask could be anywhere from 5-40 characters and so the example above would not work. I've tried lpad
and rpad
to standardize the lengths but it doesn't work for the shorter numbers.
Does anyone have any ideas or have done Alberti or Caesar ciphering in SQL on a varying character column? I would need an algorithm that could be reversed as well so I could decrypt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Translate()函数可以执行字符替换-e href =“ https://docs.aws.amazon.com/redshift/latest/dg/r_translate.html” rel =“ nofollow noreferrer”> htttps:// docs。 aws.amazon.com/redshift/latest/dg/r_translate.html
只需提供凯撒(Caesar Cypher)作为chars_to_to_replace和chars_to_to_substitute strings。
======================================
来自wikipedia- https://en.wikipedia.org/wikipedia.org/wiki/wiki/caesar_cipher
The translate() function can perform character substitutions - https://docs.aws.amazon.com/redshift/latest/dg/r_TRANSLATE.html
Just provide the caesar cypher as the chars_to_replace and chars_to_substitute strings.
===========================================
For example performing the caesar cypher example from wikipedia - https://en.wikipedia.org/wiki/Caesar_cipher
我能够使用SAS创建一个工作,这使我可以使用上面描述的技术将输出复制并粘贴到我的SQL语句中,并使用一堆
substring
语句:I was able to create a work-around using SAS which allows me to copy and paste the output into my SQL statement using the technique I described above with a bunch of
substring
statements: