473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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
{
KeyPairGenerator keypairgenerator =
KeyPairGenerator.getInstance("DSA");
SecureRandom sec = new SecureRandom(s);

keypairgenerator.initialize(512, sec);
a = keypairgenerator.generateKeyPair().getPrivate();
}
catch (NoSuchAlgorithmException nosuchalgorithmexception)
{
System.err.println(nosuchalgorithmexception);
}

try
{
Signature signature = Signature.getInstance("DSA");
signature.initSign(a);
signature.update(key);
byte1 = signature.sign();
}
catch (Exception exception)
{
System.err.println(exception);
}

System.out.println(byte1.length ); // suns java ~46 byte long, MS J#
only 40 bytes :-(

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

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

Similar topics

6
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...
2
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...
0
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...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
2
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...
4
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...
2
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...
2
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...
1
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...
6
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.