Skip to content

Instantly share code, notes, and snippets.

View akwasiio's full-sized avatar

Isaac akwasiio

View GitHub Profile
@akwasiio
akwasiio / cbc_decryption.rs
Created February 23, 2024 19:26
Rust code for encrypting & decrypting plaintext using cbc
pub fn cbc_decryption(key_stream: &[u8], cipher: &[u8], init_vector: &[u8]) -> Vec<u8> {
let mut res = Vec::new();
let chunked: Vec<&[u8]> = cipher.chunks(16).collect();
chunked
.iter()
.enumerate()
.for_each(|(index, cipher_chunk)| {
let last = if index == 0 {
init_vector
} else {
@akwasiio
akwasiio / Randombox.kt
Created December 13, 2023 13:44
A random box I was asked to build lol
@Composable
fun RandomBox() {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.height(IntrinsicSize.Min)
.padding(100.dp)
.border(width = 1.dp, shape = RoundedCornerShape(6.dp), color = Color.Gray)
) {
for (i in 1..4) {
@akwasiio
akwasiio / Board.kt
Created October 10, 2023 03:45
Simple Tic Tac Toe Game between two players
enum class Player {
X, O
}
class Board {
private val slots = "1,2,3,4,5,6,7,8,9".split(",").toTypedArray()
fun show() {
for ((index, item) in slots.withIndex()) {
print(item)
@akwasiio
akwasiio / pglatin.kt
Last active October 4, 2023 01:12
Simple pig latin implementation
fun Char.isVowel(): Boolean {
return "aeiou".contains(lowercaseChar())
}
fun String.toPigLatin(): String {
if (isEmpty()) return this
if (this[0].isVowel()) {
return this + "way"
}
@akwasiio
akwasiio / rc-cracklepop.kt
Created October 3, 2023 15:06
Code for RC's CracklePop question
fun main() {
for (i in 1 .. 100) {
when {
i % 3 == 0 && i % 5 == 0 -> println("CracklePop")
i % 3 == 0 -> println("Crackle")
i % 5 == 0 -> println("Pop")
else -> println(i)
@SuppressLint("ViewConstructor")
class AndroidComposeView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
// add extra params here
) : AbstractComposeView(context, attrs, defStyleAttr) {
@Composable
override fun Content() {
@Composable
fun MultipleProgressBar(steps: Int = 4, currentStep: Int) {
Row(
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
.height(48.dp)
.fillMaxWidth()
.padding(24.dp, 0.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
for (index in 0 until steps) {
static void ReadFile(String filePath) {
ArrayList<String> messageTypeList = new ArrayList<>();
ArrayList<String> transactionTypeList = new ArrayList<>();
ArrayList<String> responseCodeList = new ArrayList<>();
ArrayList<String> systemTraceList = new ArrayList<>();
try (BufferedReader oBufferedReader = new BufferedReader(new FileReader(filePath))) {
String strLine;
oBufferedReader.readLine(); // skips the first line
//
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ViewProfileScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
@akwasiio
akwasiio / country_codes.xml
Created June 26, 2018 12:34
country_codes
<string-array name="CountryCodes">
<item>93,AF</item>
<item>355,AL</item>
<item>32,BE</item>
<item>269,KM</item>
<item>682,CK</item>
<item>213,DZ</item>
<item>501,BZ</item>
<item>506,CR</item>
<item>1-684,AS</item>