<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: .Net Encryption and Oracle Decryption</title>
	<atom:link href="http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/feed/" rel="self" type="application/rss+xml" />
	<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/</link>
	<description>Technology across minds.....</description>
	<lastBuildDate>Sat, 07 Nov 2009 05:16:49 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aleksey</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-113</link>
		<dc:creator>Aleksey</dc:creator>
		<pubDate>Thu, 04 Jun 2009 17:25:17 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-113</guid>
		<description>I implemented similar. Just wants to make sure it is same as hextoraw/rawtohex.</description>
		<content:encoded><![CDATA[<p>I implemented similar. Just wants to make sure it is same as hextoraw/rawtohex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Franklin</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-112</link>
		<dc:creator>Franklin</dc:creator>
		<pubDate>Thu, 04 Jun 2009 17:23:19 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-112</guid>
		<description>I really cant remember now. It was written by another author. I believe when she is available she will respond. 
Until then, check out this link

http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa-in-c

Hope it helps!!</description>
		<content:encoded><![CDATA[<p>I really cant remember now. It was written by another author. I believe when she is available she will respond.<br />
Until then, check out this link</p>
<p><a href="http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa-in-c" rel="nofollow">http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa-in-c</a></p>
<p>Hope it helps!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleksey</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-110</link>
		<dc:creator>Aleksey</dc:creator>
		<pubDate>Thu, 04 Jun 2009 16:28:58 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-110</guid>
		<description>Sorry, but where to get that ByteArrayToHexString function?
As I understand it is the same as rawtohex, as well as HexStringToByteArray same as hextoraw?</description>
		<content:encoded><![CDATA[<p>Sorry, but where to get that ByteArrayToHexString function?<br />
As I understand it is the same as rawtohex, as well as HexStringToByteArray same as hextoraw?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suad</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-49</link>
		<dc:creator>Suad</dc:creator>
		<pubDate>Fri, 31 Oct 2008 10:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-49</guid>
		<description>Hi hansw,

The line:
numpad:=substr(result,length(result)-2); 

returns the last 2 characters which represent the number of hex characters that have been padded by the .Net padding method (ANSIX923) which is in our example 07.

The .Net padding method (ANSIX923) always pad the string your are encrypting even if the string was of the specified block size. Thus the code always gives you the correct answer. 

Thanks,
Suad</description>
		<content:encoded><![CDATA[<p>Hi hansw,</p>
<p>The line:<br />
numpad:=substr(result,length(result)-2); </p>
<p>returns the last 2 characters which represent the number of hex characters that have been padded by the .Net padding method (ANSIX923) which is in our example 07.</p>
<p>The .Net padding method (ANSIX923) always pad the string your are encrypting even if the string was of the specified block size. Thus the code always gives you the correct answer. </p>
<p>Thanks,<br />
Suad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-48</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Thu, 30 Oct 2008 12:52:55 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-48</guid>
		<description>Hi Nitin,
  We have also been in the same boat as you are right now. We also tried to override the default behaviour of Oracle DBMS_OBFUSCATION_TOOLKIT but unfortunately it is not supported. However, if you were to use the new package DBMS_CRYPTO which is more powerful and advanced, this does give you these facilities(I guess this is in 10g Oracle DB only).

We were encrypting data(in the example above) with C# and decrypting it with PL/SQL. Here C# had PaddingMode.ANSIX923 standard followed. If you read how  ANSIX923 padding works with encryption you can easily write your decrypter in PL/SQL.

In your case you are encrypting data with PL/SQL. I would suggest that you pad data as per ANSIX923  standard and use C# decryption to decrypt the data. Would work like a charm. Let me know if it works out.</description>
		<content:encoded><![CDATA[<p>Hi Nitin,<br />
  We have also been in the same boat as you are right now. We also tried to override the default behaviour of Oracle DBMS_OBFUSCATION_TOOLKIT but unfortunately it is not supported. However, if you were to use the new package DBMS_CRYPTO which is more powerful and advanced, this does give you these facilities(I guess this is in 10g Oracle DB only).</p>
<p>We were encrypting data(in the example above) with C# and decrypting it with PL/SQL. Here C# had PaddingMode.ANSIX923 standard followed. If you read how  ANSIX923 padding works with encryption you can easily write your decrypter in PL/SQL.</p>
<p>In your case you are encrypting data with PL/SQL. I would suggest that you pad data as per ANSIX923  standard and use C# decryption to decrypt the data. Would work like a charm. Let me know if it works out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nitin</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-47</link>
		<dc:creator>nitin</dc:creator>
		<pubDate>Thu, 30 Oct 2008 12:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-47</guid>
		<description>Hi,

Due to the difference between Oracle and C# I could not decrypt the data on the file, the only possible way is to change the default setting of the Oracle&#039;s built-in dbms_obfuscation_toolkit that generates the file, then we can decrypt data by using C#; 

please help me to find solution. oracle pl/sql code is 
CREATE OR REPLACE package body sp_crypt as

Function encrypt(unencrypted_string in varchar2)
  return varchar2 Is

ls_in_string		varchar2(64) := rpad(unencrypted_string,24,&#039; &#039;);
ls_key_string	        varchar2(64) := &#039;b0st0nrs&#039;;
ls_encrypted_string	varchar2(256);
lr_in_string		raw(2048);
lr_key			raw(2048);

Begin

  If (ls_in_string is NULL) Then
    return(NULL);
  Else
    lr_in_string := utl_raw.cast_to_raw(ls_in_string);
    lr_key := utl_raw.cast_to_raw(ls_key_string);

    dbms_obfuscation_toolkit.DESEncrypt(input =&gt; lr_in_string,
				      key =&gt; lr_key,
				      encrypted_data =&gt; ls_encrypted_string);

    return(ls_encrypted_string);
  End If;

End encrypt;

Function decrypt(encrypted_string in varchar2)
  return varchar2 Is

ls_key_string	        varchar2(64) := &#039;b0st0nrs&#039;;
lr_key			raw(2048) := utl_raw.cast_to_raw(ls_key_string);
ls_unencrypted_string	varchar2(64);

Begin

  If (encrypted_string is NULL) Then
    return(NULL);
  Else
    dbms_obfuscation_toolkit.DESDecrypt(input =&gt; encrypted_string,
				      key =&gt; lr_key,
				      decrypted_data =&gt; ls_unencrypted_string);

    return(rtrim(utl_raw.cast_to_varchar2(ls_unencrypted_string)));
  End If;

End decrypt;

End sp_crypt;
/




Thanks
Nitin</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Due to the difference between Oracle and C# I could not decrypt the data on the file, the only possible way is to change the default setting of the Oracle&#8217;s built-in dbms_obfuscation_toolkit that generates the file, then we can decrypt data by using C#; </p>
<p>please help me to find solution. oracle pl/sql code is<br />
CREATE OR REPLACE package body sp_crypt as</p>
<p>Function encrypt(unencrypted_string in varchar2)<br />
  return varchar2 Is</p>
<p>ls_in_string		varchar2(64) := rpad(unencrypted_string,24,&#8217; &#8216;);<br />
ls_key_string	        varchar2(64) := &#8216;b0st0nrs&#8217;;<br />
ls_encrypted_string	varchar2(256);<br />
lr_in_string		raw(2048);<br />
lr_key			raw(2048);</p>
<p>Begin</p>
<p>  If (ls_in_string is NULL) Then<br />
    return(NULL);<br />
  Else<br />
    lr_in_string := utl_raw.cast_to_raw(ls_in_string);<br />
    lr_key := utl_raw.cast_to_raw(ls_key_string);</p>
<p>    dbms_obfuscation_toolkit.DESEncrypt(input =&gt; lr_in_string,<br />
				      key =&gt; lr_key,<br />
				      encrypted_data =&gt; ls_encrypted_string);</p>
<p>    return(ls_encrypted_string);<br />
  End If;</p>
<p>End encrypt;</p>
<p>Function decrypt(encrypted_string in varchar2)<br />
  return varchar2 Is</p>
<p>ls_key_string	        varchar2(64) := &#8216;b0st0nrs&#8217;;<br />
lr_key			raw(2048) := utl_raw.cast_to_raw(ls_key_string);<br />
ls_unencrypted_string	varchar2(64);</p>
<p>Begin</p>
<p>  If (encrypted_string is NULL) Then<br />
    return(NULL);<br />
  Else<br />
    dbms_obfuscation_toolkit.DESDecrypt(input =&gt; encrypted_string,<br />
				      key =&gt; lr_key,<br />
				      decrypted_data =&gt; ls_unencrypted_string);</p>
<p>    return(rtrim(utl_raw.cast_to_varchar2(ls_unencrypted_string)));<br />
  End If;</p>
<p>End decrypt;</p>
<p>End sp_crypt;<br />
/</p>
<p>Thanks<br />
Nitin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hansw</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-42</link>
		<dc:creator>hansw</dc:creator>
		<pubDate>Wed, 22 Oct 2008 07:23:37 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-42</guid>
		<description>I&#039;ve found a small bug in your PL/SQL code.
The line:
numpad:=substr(result,length(result)-2);

returns the last three characters, this leed to an error if length of the last block is seven and the last digit of the hex value is  != 0.
eg if you encrypt strings like &#039;123456#&#039; or &#039;ABCDEFGH123456#&#039;
you can&#039;t decrypt them.
Change line 11 of your listing to:
numpad:=substr(result,length(result)-1);
Then everythink works fine!

Thanks for your excellent example!  ;)</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found a small bug in your PL/SQL code.<br />
The line:<br />
numpad:=substr(result,length(result)-2);</p>
<p>returns the last three characters, this leed to an error if length of the last block is seven and the last digit of the hex value is  != 0.<br />
eg if you encrypt strings like &#8216;123456#&#8217; or &#8216;ABCDEFGH123456#&#8217;<br />
you can&#8217;t decrypt them.<br />
Change line 11 of your listing to:<br />
numpad:=substr(result,length(result)-1);<br />
Then everythink works fine!</p>
<p>Thanks for your excellent example!  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chinaman</title>
		<link>http://javasight.wordpress.com/2008/08/24/net-encryption-and-oracle-decryption/#comment-22</link>
		<dc:creator>chinaman</dc:creator>
		<pubDate>Thu, 18 Sep 2008 03:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://javasight.wordpress.com/?p=54#comment-22</guid>
		<description>Hi 
It&#039;s better to put reference link</description>
		<content:encoded><![CDATA[<p>Hi<br />
It&#8217;s better to put reference link</p>
]]></content:encoded>
	</item>
</channel>
</rss>
