Skip to content

Instantly share code, notes, and snippets.

James Wahome Jaymo

Block or report user

Report or block Jaymo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SealedBoxUtility.java
package org.timby.crypto;
import org.timby.util.TweetNaclFast;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import ove.crypto.digest.Blake2b;
/**
View TypefaceHelper.java
import android.content.Context;
import android.graphics.Typeface;
import android.support.v4.util.SimpleArrayMap;
public class TypefaceHelper {
private static final SimpleArrayMap<String, Typeface> cache = new SimpleArrayMap<>();
public static Typeface get(Context c, String name) {
synchronized (cache) {
View createCipher.java
public static Cipher createCipher(int mode,SecretKey key,String iv) throws Exception {
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding", "BC");
cipher.init(
Cipher.DECRYPT_MODE,
new SecretKeySpec(key, "AES"),
new IvParameterSpec(Util.HexEncoder.toByte(iv))
);
View applyCipher.java
private final static int DEFAULT_READ_WRITE_BLOCK_BUFFER_SIZE = 1024;
public static void applyCipher(String inFile, String outFile, Cipher cipher) throws Exception {
CipherInputStream in = new CipherInputStream(new FileInputStream(inFile), cipher);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
byte[] buffer = new byte[DEFAULT_READ_WRITE_BLOCK_BUFFER_SIZE];
int count = 0;
while ((count = in.read(buffer)) >= 0) {
View generateIv.java
private static final String RANDOM_ALGORITHM = "SHA1PRNG";
public static final int IV_LENGTH = 16;
private byte[] generateIv() throws NoSuchAlgorithmException, NoSuchProviderException {
SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM);
byte[] iv = new byte[IV_LENGTH];
random.nextBytes(iv);
return iv;
}
View generateSalt.java
public static final int SALT_LENGTH = 256;
private static final String RANDOM_ALGORITHM = "SHA1PRNG";
public String generateSalt() throws CryptoException {
try {
SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM);
byte[] salt = new byte[SALT_LENGTH];
random.nextBytes(salt);
String saltHex = Util.HexEncoder.toHex(salt);
return saltHex;
View getSecretKey.java
public static final int PBE_ITERATION_COUNT = 10000; //Am not sure on this size and low end devices. I should test more to prevent lag
private static final String PBE_ALGORITHM = "PBKDF2WithHmacSHA1";
public static final String PROVIDER = "BC";
private static final String SECRET_KEY_ALGORITHM = "AES/GCM/NoPadding;
public static SecretKey getSecretKey(String password, String salt) throws CryptoException {
try {
PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(), Util.HexEncoder.toByte(salt), PBE_ITERATION_COUNT, 256);
SecretKeyFactory factory = SecretKeyFactory.getInstance(PBE_ALGORITHM, PROVIDER);
SecretKey tmp = factory.generateSecret(pbeKeySpec);
@Jaymo
Jaymo / file.rb
Created Aug 9, 2014
Take a look at "PesaBox"
View file.rb
https://play.google.com/store/apps/details?id=com.myitprovider.pesabox
@Jaymo
Jaymo / volleyHenry.java
Created Jun 16, 2014
Volley: passing parameters in a string request
View volleyHenry.java
StringRequest loginReq = new StringRequest(Method.GET,
URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
respnse=response;
}
}, new Response.ErrorListener() {
@Jaymo
Jaymo / OkHttpStack.java
Last active Aug 29, 2015
A `HttpStack` implementation for Volley that uses OkHttp 2.0 as its transport.
View OkHttpStack.java
package com.ujuzicode.repocode;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
/**
You can’t perform that action at this time.