473,761 Members | 4,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suns java into J# DSA Problem

If I use this little Prg under Sun's Java, the outputbytearray (byte1) is ~46
bytes long! If I use it under J# the outputbytearray (byte 1) is all the time
only 40 bytes long! Can anyone show me how to correct this problem? I can't
use the "generated" key anymore under J#, because the bytelenght differs
from the one in java. Or maybe anyone can traslate it into c#?

Here is the source :

import java.security.* ;

public class Untitled1
{

public static PrivateKey a;

public static void main(String[] args)
{
byte key[] = { 1,2,3,4,5,6,7,8 };

byte s[] = { 19, 120, 108, 92, 115, 33, -119,-38, -97, -77, -49, 27, 6,
78, -90, 105, -102, 87, -110, -90 };

byte byte1[] = new byte[0];

try
{
KeyPairGenerato r keypairgenerato r =
KeyPairGenerato r.getInstance(" DSA");
SecureRandom sec = new SecureRandom(s) ;

keypairgenerato r.initialize(51 2, sec);
a = keypairgenerato r.generateKeyPa ir().getPrivate ();
}
catch (NoSuchAlgorith mException nosuchalgorithm exception)
{
System.err.prin tln(nosuchalgor ithmexception);
}

try
{
Signature signature = Signature.getIn stance("DSA");
signature.initS ign(a);
signature.updat e(key);
byte1 = signature.sign( );
}
catch (Exception exception)
{
System.err.prin tln(exception);
}

System.out.prin tln(byte1.lengt h ); // suns java ~46 byte long, MS J#
only 40 bytes :-(

for (int i = 0; i < byte1.length; i++)
{
System.out.prin t((int)byte1[i] + " ");
}
}
}
Nov 22 '05 #1
0 1124

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
24741
by: Steven Green | last post by:
I have a java app at work I used when I had Windows 98 and never had a problem. I did a clean install of Windows XP and of course Java was not included. I went to Sun, download Java 2 Runtime Environment, SE v 1.4.2 and Java 2 Runtime Environment SE v 1.4.1_01. The Java app will not work with WinCP. I have installed the Windows XP Service pack 1, IE service pack 1 and I have downloaded Netscape and Opera. The same problem happens in...
2
3959
by: Patrick | last post by:
I'm using Jakarta-POI to create a huge Excel spreadsheet. I get the error below when the spreadsheet grows to a large size. It seems to have something to do with the number of "cell" objects that I create. If I destroy other objects that I don't need any more, then I can create more "cell" objects. Unfortunately, I cannot destroy any more of my other objects without breaking the program. This does not appear to be a problem that is...
0
272
by: toxxi | last post by:
If I use this little Prg under Sun's Java, the outputbytearray (byte1) is ~46 bytes long! If I use it under J# the outputbytearray (byte 1) is all the time only 40 bytes long! Can anyone show me how to correct this problem? I can't use the "generated" key anymore under J#, because the bytelenght differs from the one in java. Or maybe anyone can traslate it into c#? Here is the source : import java.security.*;
133
8581
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
2
9244
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
4
4152
by: Izak van Langevelde | last post by:
Shocks. Today I came to learn that Suns jdbc-odbc bridge driver isn't meant for serious purposes; it's experimental. I already knew it isn't thread safe, but didn't think of this as problematic for the relatively simple system I'm using it. However, I suspect there are other issues. Currently I'm stuck with a query which takes less than one second if I run it somewhere in my program's main thread, while it takes easily 40 seconds when I...
2
3149
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored procedures. It is enabled for SQL stored procedures. It is possible to "Build" and "Run" the Java SPs, it just isn't possible to click on the "Build for Debug" option. Thanks for any help in advance. Michael
2
13519
by: Tim Murray | last post by:
First of all, I don't know much about Java, even its naming and version numbering nomenclature, and second, if there is a better group to ask this in, please let me know. System is Mac with 10.4.4. I have Java 1.3.1 and 1.4.2 plug-ins, and J2SE 5.0 (1.5.0) installed. The Java preferences application lets me choose J2SE 5 or 1.4.2 to run applets via a browser. The problem happens in both settings. The problem is that we have a...
1
9651
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
6
2438
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the UnsatisfiedLinkError has something to do with a DLL that is not visible but I'm not sure why I'm having the problem given that both db2java.zip and db2jcc.jar are visible on my classpath and each of them contain the COM.ibm.db2.app.UDF class with a...
0
9353
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9788
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6623
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.