Skip to content

Instantly share code, notes, and snippets.

private static void genCert
(String id, String pass, File pubfile, File secfile)
throws Exception
{
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
kpg.initialize(2048);
KeyPair sign_pair = kpg.generateKeyPair();
KeyPair enc_pair = kpg.generateKeyPair();
@kbsriram
kbsriram / gist:2050672
Created March 16, 2012 15:57
anonymous keyid recipients
import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.bcpg.ContainedPacket;
import org.bouncycastle.bcpg.PublicKeyEncSessionPacket;
public class CAnonymousPublicKeyKeyEncryptionMethodGenerator
extends BcPublicKeyKeyEncryptionMethodGenerator
{
public CAnonymousPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key)
@kbsriram
kbsriram / gist:4074271
Created November 14, 2012 19:40
SQLiteOpenHelper.java
/*
* Copyright (C) 2007 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
// Underhanded skullduggery to access the keystore daemon.
//
// This is merely a slightly cleaned up implementation of
// http://nelenkov.blogspot.com/2012/05/storing-application-secrets-in-androids.html
// and all credit to Nikolay for digging into this.
package org.kbsriram.android.util;
import android.content.Context;
import android.content.Intent;
package org.ppdrive.crypto;
import java.io.File;
import java.io.FileInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.SecureRandom;
package org.ppdrive.crypto;
import org.bouncyrattle.bcpg.ContainedPacket;
import org.bouncyrattle.bcpg.PublicKeyEncSessionPacket;
import org.bouncyrattle.openpgp.PGPException;
import org.bouncyrattle.openpgp.PGPPublicKey;
import org.bouncyrattle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
class CAnonymousPublicKeyKeyEncryptionMethodGenerator
extends BcPublicKeyKeyEncryptionMethodGenerator
@kbsriram
kbsriram / PF1Coder.java
Created July 27, 2013 00:44
PF1 encoding for PGP fingerprints.
// PF1-encoding for PGP fingerprints; optimized to fit
// within a Version 2 QR code using M-level error-correction
//
// Format is simple.
// PF1:<32 characters -- Base32 (rfc4648) encoded 160 bit fingerprint>
//
// To test:
//
// $ java PF1Coder encode <40-character hex fingerprint>
// PF1:<....>
@kbsriram
kbsriram / Gen.java
Created November 24, 2013 21:48
simple emacs tags generator for java source - only indexes classes and interfaces.
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
import java.io.Reader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StreamTokenizer;
My pgp fingerprint is BF71 A5E8 E8CD 553B DE86 0969 62F4 63C6 73F6 C01F