Skip to content

Instantly share code, notes, and snippets.

View lry127's full-sized avatar
🤭
Trial & Error

lry127 lry127

🤭
Trial & Error
View GitHub Profile
@lry127
lry127 / AESCBCCryptoWrapper.java
Last active January 2, 2024 14:58
Java AES CBC encryption (decryption) util with example.
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
@berkedel
berkedel / import-x509-pk8-to-jks-keystore.md
Created October 12, 2020 10:43
How to import x509.pem pk8 file into jks keystore

How to import x509.pem pk8 file into jks keystore

Prerequiste:

Generate a file platform.priv.pem from you pk8 file.

openssl pkcs8 -in platform.pk8 -inform DER -outform PEM -out platform.priv.pem -nocrypt
@nielsutrecht
nielsutrecht / RsaExample.java
Created December 21, 2016 09:55
Example of using RSA in Java to sign/verify and encrypt/decryt
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.Signature;
public class RsaExample {
public static void main(String... argv) throws Exception {
//First generate a public/private key pair
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active July 27, 2024 06:18
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
//
// !!WARNING: Not recommended for production code!!
//
public class ClassLoaderActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
// file.jar has a dex'd "classes.dex" entry that you can generate with "dx" from any number of JARs or class files
ClassLoader dexLoader = new DexClassLoader("/path/to/file.jar", getCacheDir().getAbsolutePath(), null, getClassLoader());
setAPKClassLoader(dexLoader);
public class Dexter {
private static String optimizedDirectory = "optimized";
private static String workDirectory = "working";
public static void loadFromAssets(Context context, String fileName) throws Exception {
File optimized = new File(optimizedDirectory);
optimized = context.getDir(optimized.toString(), Context.MODE_PRIVATE);
optimized = new File(optimized, fileName);
@sp3c73r2038
sp3c73r2038 / post.py
Last active April 7, 2023 15:27
urlopen with proxy support
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import urllib2
data = urllib2.urlencode({'foo': 'bar'})
r = urllib2.Request('https://www.google.com', # url
data, # post data
@marshall
marshall / ClassLoaderActivity.java
Created February 22, 2011 17:16
A reflection hack to override the APK ClassLoader so you can launch Activities in an external JAR.
//
// !!WARNING: Not recommended for production code!!
//
public class ClassLoaderActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
// file.jar has a dex'd "classes.dex" entry that you can generate with "dx" from any number of JARs or class files
ClassLoader dexLoader = new DexClassLoader("/path/to/file.jar", getCacheDir().getAbsolutePath(), null, getClassLoader());
setAPKClassLoader(dexLoader);
@schacon
schacon / gist:1
Created July 15, 2008 18:17
the meaning of gist
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.