Click here to Skip to main content
15,881,173 members
Home / Discussions / C#
   

C#

 
AnswerRe: causing the computer to freeze Pin
OriginalGriff2-Jan-22 6:29
mveOriginalGriff2-Jan-22 6:29 
GeneralRe: causing the computer to freeze Pin
Calin Negru3-Jan-22 6:13
Calin Negru3-Jan-22 6:13 
GeneralRe: causing the computer to freeze Pin
OriginalGriff3-Jan-22 6:45
mveOriginalGriff3-Jan-22 6:45 
AnswerRe: causing the computer to freeze Pin
#realJSOP2-Jan-22 23:53
mve#realJSOP2-Jan-22 23:53 
AnswerRe: causing the computer to freeze Pin
0x01AA5-Jan-22 4:40
mve0x01AA5-Jan-22 4:40 
QuestionAsync/Await Questions Pin
Kevin Marois30-Dec-21 7:35
professionalKevin Marois30-Dec-21 7:35 
AnswerRe: Async/Await Questions Pin
Gerry Schmitz30-Dec-21 18:43
mveGerry Schmitz30-Dec-21 18:43 
QuestionRead signature data from APK's RSA signature file Pin
mynametaken30-Dec-21 4:46
mynametaken30-Dec-21 4:46 
I have the source in java that reads signature data from RSA (erxtracted from APK (Android Package) file) and it works flawlessly but i would like to convert to C# in order to use in my c# application. The issue is i'm getting different data from GetRawCertData() no matter what I have tried.

This is the result:
C#: AQAAADCCBYkwggNxoAMCAQICFQDmX5cziG0zO22ity1a/dKI6FnZyzANBgk...
Java: AQAABY0wggWJMIIDcaADAgECAhUA5l+XM4htMzttorctWv3SiOhZ2cswDQYJKoZIhvcNA...

I'm not familar with signatures, and i'm not even sure what excat format is it but I know it is signed with Java's KeyStore file.

What should I do to get it right? it is very close though. Executing .jar file would be a workaround but I would like to avoid executing something externally

This is my C# code
C#
X509Certificate cert = X509Certificate.CreateFromSignedFile("BNDLTOOL.RSA");

MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(1);

byte[] data = cert.GetRawCertData();
bw.Write(data);
bw.Write(data.Length);

byte[] buffer = ms.ToArray();

Debug.WriteLine(Convert.ToBase64String(buffer));


This is Java code from a project that I found online
Java
PKCS7 pkcs7 = new PKCS7(StreamUtil.readBytes(zipFile.getInputStream(ze)));
Certificate[] certs = pkcs7.getCertificates();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.write(certs.length);
for (int i = 0; i < certs.length; i++) {
    byte[] data = certs[i].getEncoded();
    System.out.printf("  --SignatureHash[%d]: %08x\n", i, Arrays.hashCode(data));
    dos.writeInt(data.length);
    dos.write(data);
}
byte[] signatures = baos.toByteArray();
System.out.println(Base64.getEncoder().encodeToString(signatures));


modified 1-Jan-22 11:52am.

AnswerRe: Read signature data from APK's RSA signature file Pin
jschell30-Dec-21 7:35
jschell30-Dec-21 7:35 
GeneralRe: Read signature data from APK's RSA signature file Pin
mynametaken1-Jan-22 5:53
mynametaken1-Jan-22 5:53 
AnswerRe: Read signature data from APK's RSA signature file Pin
Luc Pattyn30-Dec-21 7:44
sitebuilderLuc Pattyn30-Dec-21 7:44 
GeneralRe: Read signature data from APK's RSA signature file Pin
mynametaken1-Jan-22 5:56
mynametaken1-Jan-22 5:56 
GeneralRe: Read signature data from APK's RSA signature file Pin
Luc Pattyn1-Jan-22 5:59
sitebuilderLuc Pattyn1-Jan-22 5:59 
GeneralRe: Read signature data from APK's RSA signature file Pin
mynametaken9-Jan-22 4:37
mynametaken9-Jan-22 4:37 
AnswerRe: Read signature data from APK's RSA signature file Pin
jschell23-Jan-22 6:49
jschell23-Jan-22 6:49 
QuestionWinform support in Windows service Pin
Member 1260803929-Dec-21 23:59
Member 1260803929-Dec-21 23:59 
AnswerRe: Winform support in Windows service Pin
OriginalGriff30-Dec-21 0:27
mveOriginalGriff30-Dec-21 0:27 
GeneralRe: Winform support in Windows service Pin
Member 1260803930-Dec-21 1:28
Member 1260803930-Dec-21 1:28 
GeneralRe: Winform support in Windows service Pin
OriginalGriff30-Dec-21 2:08
mveOriginalGriff30-Dec-21 2:08 
AnswerRe: Winform support in Windows service Pin
#realJSOP30-Dec-21 1:20
mve#realJSOP30-Dec-21 1:20 
QuestionDynamically change int from a string Pin
Matte Matik29-Dec-21 12:02
Matte Matik29-Dec-21 12:02 
AnswerRe: Dynamically change int from a string Pin
Dave Kreskowiak29-Dec-21 12:36
mveDave Kreskowiak29-Dec-21 12:36 
AnswerRe: Dynamically change int from a string Pin
OriginalGriff29-Dec-21 21:53
mveOriginalGriff29-Dec-21 21:53 
QuestionC# Entity Framework : how to generate custom automatic numbers Pin
Fidele Okito27-Dec-21 4:50
Fidele Okito27-Dec-21 4:50 
AnswerRe: C# Entity Framework : how to generate custom automatic numbers Pin
Gerry Schmitz27-Dec-21 5:16
mveGerry Schmitz27-Dec-21 5:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.