需要对teradata SQL Query中的数据进行加密 [英] Need to encrypt the data in teradata SQL Query

查看:34
本文介绍了需要对teradata SQL Query中的数据进行加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 SQL 查询或存储过程对 teradata 中的数据进行加密.
我在以下示例中有数据:

I have requirement to encrypt the data in teradata using SQL Query or Stored procedure.
I have data in below sample:

May123@34@#
AbC@#$%1234DE#f
zyx@12

所以我想要以下格式的输出

So I want output in the below format

aaadddpddpp
aaappppddddaapa
aaapdd

所以我们想用 a 替换字符,用 d 替换数字,用 p 替换特殊字符.

So we want to replace character with a and number with d and special character with p.

非常感谢您的帮助.

推荐答案

这看起来像是数据屏蔽,而不是加密.加密是您可以通过解密撤消的事情,其中​​掩码是一种单向的事情.

This looks like data masking, not encryption. Encryption is something you can undo with decryption where masking is a one-way thing.

您可以使用 Regexp_Replace() 进行交换:

You can use Regexp_Replace() to do the swaps:

SELECT REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE('May123@34@#', '[a-z]', 'a', 1, 0, 'i'),'[0-9]', 'd', 1, 0, 'i'), '[^a-z]', 'p', 1, 0, 'i')

结果:

aaadddpddpp

这首先将所有字母交换为 a.然后它将所有数字交换为 d.最后,剩下的任何东西都被交换到 p.

This first swaps all letters to a. Then it swaps all numbers to d. Finally anything left over is swapped to p.

这篇关于需要对teradata SQL Query中的数据进行加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆