Skip to content

Instantly share code, notes, and snippets.

View DrBrad's full-sized avatar
💭
Learning Rust

Brad DrBrad

💭
Learning Rust
View GitHub Profile
@DrBrad
DrBrad / CipherInputStream.java
Created March 25, 2024 22:16
Improved CipherInputStream & CipherOutputStream
import javax.crypto.Cipher;
import javax.crypto.NullCipher;
import javax.crypto.ShortBufferException;
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class CipherInputStream extends FilterInputStream {
@DrBrad
DrBrad / hpe_sos_ubuntu.md
Created December 28, 2023 08:06 — forked from yukirii/hpe_sos_ubuntu.md
installing HPE StoreOpen Software for RHELx64 to Ubuntu 20.04.2 LTS (Reference: https://rabbit-note.com/2020/01/12/ubuntu-ltfs/)
@DrBrad
DrBrad / curlparse.c
Last active January 27, 2022 20:36
URL parser for C-Lang
#include <stdio.h>
#include <string.h>
typedef struct {
char *protocol;
char *host;
char *path;
int port;
} URL;
@DrBrad
DrBrad / client.java
Last active March 14, 2021 12:40
UDP Hole Punching Java
public static void main(String[] args){
try{
DatagramSocket s = new DatagramSocket();
byte[] b = new byte[10];
DatagramPacket p = new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 8000);
s.send(p);
p = new DatagramPacket(new byte[65535], 65535);
s.receive(p);
@DrBrad
DrBrad / README.md
Last active July 12, 2021 19:25
Java Swing Relative Layout Manager

I tried to make the layout as similar as possible to androids relative layout, as feel that it is the superior layout.

Heres an example:

pane.add(mjlabel, new RelativeConstraints().alignParentRight().toRightOf(mjlabel1).setHeight(RelativeConstraints.MATCH_PARENT));

@DrBrad
DrBrad / SRI.java
Last active September 20, 2020 18:35
Socket Cipher Data Input / Output Stream for AES
import javax.crypto.Cipher;
import javax.crypto.NullCipher;
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
public class SRI extends FilterInputStream {
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.DocumentTraversal;
import org.w3c.dom.traversal.NodeFilter;
import org.w3c.dom.traversal.NodeIterator;
import javax.xml.parsers.DocumentBuilderFactory;
import java.net.*;
import java.util.Enumeration;
@DrBrad
DrBrad / Block.java
Last active May 27, 2020 02:25
Quick and Easy BlockChain
import java.security.MessageDigest;
import java.util.Date;
import static *.BlockHandler.*;
import static java.nio.charset.StandardCharsets.UTF_8;
public class Block {
public String hash;
public String previousHash;
@DrBrad
DrBrad / SRServerSocket.java
Last active April 13, 2020 07:17
Secure Socket RSA/AES with Sessions
package org.theanarch.secure_socket;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.SocketException;
public class SRServerSocket extends ServerSocket {
public SRServerSocket(int port)throws IOException {
super(port);
@DrBrad
DrBrad / AES Example
Created February 9, 2019 08:56
AES Encryption
import android.util.Base64;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;