//DSA JAVA平台签名转成.net可以认识的签名
public static byte[] changeDSAJava2net(byte[] Content) {
byte[] RByte = new byte[40];
// byte[] SByte = new byte[20];
// byte[] Content = DERStr.getBytes();
int IntRLength = Content[3];
int j = 0;
// 第一段是 20个字符
if (IntRLength == 20) {
for (int i = 0; i < 20; i++) {
RByte[i] = Content[4 + i];
}
j = 24;
} else if (IntRLength > 20) {
// 第五位数字是0
for (int i = 0; i < 20; i++) {
RByte[i] = Content[5 + i];
}
j = 25;
} else {
// IntRLength 19 NotEnough 1
int NotEnough = 20 - IntRLength;
for (int i = 0; i < NotEnough; i++) {
// 不足数据用0补齐
RByte[i] = 0;
}
for (int i = 0; i < IntRLength; i++) {
RByte[NotEnough + i] = Content[4 + i];
}
j = 24 - NotEnough;
}
int IntSLength = Content[j + 1];
if (IntSLength == 20) {
for (int i = 0; i < 20; i++) {
RByte[i + 20] = Content[j + 2 + i];
}
} else if (IntSLength > 20) {
for (int i = 0; i < 20; i++) {
RByte[i + 20] = Content[j + 3 + i];
}
} else {
int NotEnough = 20 - IntSLength;
for (int i = 0; i < NotEnough; i++) {
RByte[i + 20] = 0;
}
for (int i = 0; i < IntSLength; i++) {
RByte[NotEnough + i + 20] = Content[j + 2 + i];
}
}
return RByte;
}
网上关于DSA的签名的实现代码很多 在此不再赘述 有疑问可以去问问百度或google
再次感谢徐某人!