Python implementation of the Java algorithm for an RFC 2253 conformant string
representation of an X.500 distinguished name with additional canonicalisations
(as used to compare distinguished names in X.509 certificates for equality in
e.g. apksigner
and Android).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.List; | |
class Test { | |
public static TestClassNoSuper tcns; | |
public static TestClassExtendsBar tceb; | |
public static class Foo {} | |
public static class Bar { | |
static { | |
System.out.println("Bar initialiser..."); | |
if (tcns != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import sys | |
import tempfile | |
import zipfile | |
classname_str, *search_dirs = sys.argv[1:] | |
classname_bytes = classname_str.encode() | |
for search_dir in search_dirs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedInputStream; | |
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.Reader; | |
import java.math.BigInteger; | |
import java.nio.charset.StandardCharsets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import struct | |
import sys | |
import zipfile | |
zfile, entry = sys.argv[1:] | |
with zipfile.ZipFile(zfile) as zf: | |
info = zf.getinfo(entry) | |
with open(zfile, "rb") as fh: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import json | |
import zipfile | |
from hashlib import sha1, sha256 | |
from asn1crypto import cms # type: ignore[import-untyped] | |
from cryptography.exceptions import InvalidSignature | |
from cryptography.hazmat.primitives import serialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
zipentry=META-INF/version-control-info.textproto | |
commit_from_zip() { | |
unzip -p -- "$1" "$zipentry" | grep revision | grep -Eo '[0-9a-f]+' | tail -1 | |
} | |
url="${1:-}" | |
if [ -z "$url" ]; then | |
read -r -p 'url> ' | |
url="$REPLY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Unicode { | |
public static void main(String[] args) { | |
String foo = "🏳️⚧️"; | |
for (String x : foo.split("")) { | |
System.out.println(x.codePointAt(0)); | |
} | |
System.out.println("---"); | |
int n = foo.codePointCount(0, foo.length()); | |
for (int i = 0; i < n; ++i) { | |
int j = foo.offsetByCodePoints(0, i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[flake8] | |
ignore = E501 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# encoding: utf-8 | |
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <[email protected]> | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
import os | |
import struct | |
import zipfile | |
from dataclasses import dataclass |
NewerOlder