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;
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
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;
@lry127
lry127 / Generator.java
Created May 3, 2024 10:35
an identifier generator used to generate a lot of confusing identifiers for code obfuscation (e.g. you can use it to generate proguard dictionary)
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Random;
/**
* an identifier generator, each generated value is guaranteed to be unique <br>
@lry127
lry127 / LinkedList.h
Last active July 1, 2024 09:58
LinkedList implementation in C++ for educational purpose
//
// Created by lry127 on 7/1/24.
//
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <algorithm>
#include <iostream>
@lry127
lry127 / D1Q1.java
Created September 10, 2024 12:02
stuck with "adventofcode" 2023 day 1 problem
import java.util.Scanner;
public class D1Q1 {
static class NumberReader {
static int parseLine(String data) {
Integer firstDigit = null, lastDigit = null;
for (char c : data.toCharArray()) {
if (Character.isDigit(c)) {
int digit = Character.getNumericValue(c);
if (firstDigit == null) {
@lry127
lry127 / D3.java
Last active September 13, 2024 11:44
Advent of code Day 3 solution in Java
import java.util.*;
public class D3 {
record Point(int row, int col) {}
static class NumberRecord {
ArrayList<Point> span = new ArrayList<>();
ArrayList<Integer> values = new ArrayList<>();
void takePoint(Point pt, int value) {
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int operand1, operand2;
char operator;
scanf("%d %c %d", &operand1, &operator, &operand2);
int result = 0;
char* print_out = NULL;