Skip to content

Instantly share code, notes, and snippets.

View soaresdiogo's full-sized avatar

Diogo Soares soaresdiogo

  • Porto - Portugal
View GitHub Profile
//Using Iteedee.ApkReader package
byte[] manifestData = null;
byte[] resourcesData = null;
using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream);
ICSharpCode.SharpZipLib.Zip.ZipEntry item;
@soaresdiogo
soaresdiogo / gist:fa5682025f1e0f8f0834e652eca3f979
Created January 29, 2019 19:06
Generate Hash to MANIFEST.MF
FileStream fs = new FileStream(@"/index-v1.json", FileMode.Open);
using (BinaryReader s = new BinaryReader(fs))
{
byte[] bytes = new byte[50 * 1024];
string hashBase64 = ParseToSha1(bytes);
Debug.WriteLine("index-v1.json: " + hashBase64);
}
//Or by text
@soaresdiogo
soaresdiogo / gist:5ff743c69207fdba42e43bc603a3c998
Created January 29, 2019 19:02
Sign File and Generate the PKCS7 "RSA"
string mapPath = HttpContext.Current.Server.MapPath("/");
string pfx = @mapPath + "/keystore.p12";
X509Certificate2 cert = new X509Certificate2(pfx, "password");
string xml = @mapPath + "/file.SF";
byte[] fileContent = System.IO.File.ReadAllBytes(xml);
ContentInfo contentInfo = new ContentInfo(fileContent);
SignedCms cms = new SignedCms(contentInfo, true);
CmsSigner signer = new CmsSigner(cert);
cms.ComputeSignature(signer);