简体   繁体   English

尝试从Oracle加密功能读取DES3加密值

[英]Trying to read DES3 encrypted value from Oracle encrypt function

I am working with legacy system which already has oracle function for encryption and decryption and I am using ODP.net in C# to communicate with Oracle DB. 我正在使用已经具有用于加密和解密的oracle功能的旧系统,并且正在C#中使用ODP.net与Oracle DB通信。

I have to encrypt value using oracle encrypt function which is using DES3 encryption algorithm in Oracle and use this encrypted value to read data from Oracle database. 我必须使用在Oracle中使用DES3加密算法的oracle加密函数对值进行加密,并使用此加密后的值从Oracle数据库读取数据。
I can call the Oracle function and it encrypts but its returning encrypted text with bunch of rectangles which are characters unable to covert so when I use this encrypted value to read data from the Oracle database, its not working meaning returning nothing. 我可以调用Oracle函数并对其进行加密,但是它返回的加密文本带有一堆矩形,这些矩形无法隐藏字符,因此当我使用此加密值从Oracle数据库读取数据时,它不起作用意味着什么也不返回。

My question is, How do I properly read the encrypted text from the Oracle encrypt function basically how can I use this returned encrypted text to read data from the oracle database? 我的问题是,基本上如何正确地从Oracle加密函数读取加密的文本,如何使用返回的加密文本从oracle数据库读取数据? This oracle encrypt function takes one input parameter to be encrypted and spit out the encrypted value. 该oracle加密函数采用一个输入参数进行加密,然后吐出加密值。 Any ideas would be helpful in any language, C# would be great. 任何想法对任何语言都将有所帮助,C#会很棒。

Thank you so much in advance. 提前非常感谢您。 God Bless You! 上帝祝福你! R [R

I'm not quite clear. 我不太清楚。

I presume you have data in Oracle that is encrypted. 我想您在Oracle中有加密的数据。 You want to pull that data from the table, then use the Oracle function to decrypt it. 您想从表中提取该数据,然后使用Oracle函数对其进行解密。

When you encrypt data you generally want to store is a RAW or BLOB because it is no longer a string and you don't want any string like character set conversion to happen on it (eg removing accents from characters). 加密数据时,通常要存储的是RAW或BLOB,因为它不再是字符串,并且您不希望在字符串上进行任何类似字符集的转换(例如,从字符中删除重音符号)。 An alternative to RAW/BLOB storage is converting the bytes to a hexadecimal representation, but that wastes a lot of storage so I wouldn't recommend it. RAW / BLOB存储的一种替代方法是将字节转换为十六进制表示形式,但这浪费了很多存储空间,因此我不建议这样做。

So the first step is to determine whether the Oracle data is stored as RAW/BLOB, HEX or whether they've used a VARCHAR2 and have used the same characterset throughout to avoid any conversion issues. 因此,第一步是确定Oracle数据是否存储为RAW / BLOB,HEX或是否已使用VARCHAR2并在整个过程中使用了相同的字符集以避免任何转换问题。 If the latter, determine the database character set (the DBA should be able to get this from v$nls_parameters, if he doesn't know it off hand). 如果是后者,请确定数据库字符集(如果DBA应该立即从v $ nls_parameters中获取该字符集,则DBA应该能够从中获取该字符集)。

Basically you need to ensure that exactly the same bytes are pushed into the decryption algorithm as were pulled from the database. 基本上,您需要确保将与从数据库中提取的字节完全相同的字节放入解密算法中。 Depending on the architecture you may be able to simply do a 根据架构,您可能可以简单地执行

SELECT decrypt(encrypted_column,:key_variable) FROM table WHERE id = ....; 从表WHERE id = ....中选择解密(encrypted_column,:key_variable)

Does the Oracle function use string data types? Oracle函数是否使用字符串数据类型? If so, you need to use the same encoding in your C# application (I don't know how though) and convert the string to bytes. 如果是这样,则需要在C#应用程序中使用相同的编码(我不知道如何)并将字符串转换为字节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM