Skip to content

Instantly share code, notes, and snippets.

View patrickfav's full-sized avatar
🐿️
Nam nam nam

Patrick Favre patrickfav

🐿️
Nam nam nam
View GitHub Profile
@patrickfav
patrickfav / BcryptMemoryLeakTest.java
Last active March 29, 2019 22:38
Very simple test for probable Memory Leak in Bcrypt Library
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Tester {
public static String[] pws = {"ZeDRJ:_tu:", "ZeDRJ:_tu1", "ZeDRJ:_tu2", "ZeDRJ:_tu3", "ZeDRJ:_tu4", "ZeD1", "ZeDRJu1", "ZeDRJ:_tu19881", "98asfhj", "adasd", "()=H)d"};
public static Random r = new Random();
public static List<BCrypt.Verifyer> verifyers = new ArrayList<>();
public static boolean introduceMemoryLeak = false;
@patrickfav
patrickfav / encrypt_img_ecb.sh
Created November 17, 2018 14:24
Encrypt .ppm file with AES-ECB to show ECB will reveal patterns
#!/bin/sh
# This is part of my blog about AES: https://medium.com/p/7616beaaade9
# Inspired by https://blog.filippo.io/the-ecb-penguin/
# Convert your image to .ppm with Gimp or Photoshop
#
# Usage: ./ecb_img <image file as ppm> <password>
# extract header and body
@patrickfav
patrickfav / AesCbcExample.java
Last active June 30, 2023 03:51
Companion code to my article about AES+CBC with Encrypt-then-MAC.
package at.favre.lib.armadillo;
import org.junit.Test;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
@patrickfav
patrickfav / example_jekyll.md
Last active January 7, 2024 19:39
A Liquid Filter for obfuscating an Email Address (can be used with Jekyll aswell).

In Jekyll set a variable for the mail, e.g. in the _config.yml

email: name@mail.com

then use it in your page

Reach me under:	{{ site.email | mailObfuscate }}

which will generate the following HTML

@patrickfav
patrickfav / RandomOrgUtil.java
Last active August 18, 2020 17:44
Random.org Signed Response Verification (Java)
/*
Copyright 2017 Patrick Favre-Bulle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / gist:d3ea9bfcb1669389f0bb52240bace1f3
Created March 3, 2017 22:50
Read out all Security Provider
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest("hallo".getBytes(Charset.forName("UTF-8")));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
@patrickfav
patrickfav / AndroidManifest.xml
Created January 30, 2017 21:17
Example for how to reproduce the restart bug in Seismic
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.company.seismicbug"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
@patrickfav
patrickfav / KeyStoreHelper.java
Created September 21, 2016 10:24 — forked from alphamu/KeyStoreHelper.java
Using Android KeyStore to generate a password. The code create a public/private key pair and uses the base64 encoded form of the certificate to as the password. The code modified the KeystoreHelper class from AOSP demo projects.
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software