Skip to content

Instantly share code, notes, and snippets.

View reuniware's full-sized avatar
🎯
Focusing

Quant & Fintech Opensource Projects reuniware

🎯
Focusing
View GitHub Profile
@reuniware
reuniware / MPAndroidChartActivity.kt
Created July 5, 2019 13:49
Kotlin MPAndroidChart Basic Code
package com.activity
import android.graphics.Color
import android.graphics.DashPathEffect
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.github.mikephil.charting.charts.LineChart
import com.github.mikephil.charting.components.Legend
import com.github.mikephil.charting.components.LimitLine
import com.github.mikephil.charting.components.LimitLine.LimitLabelPosition
@reuniware
reuniware / sha_aes_utility.kt
Last active March 29, 2024 21:18
Android Kotlin : SHA-1 Hash and AES Encryption/Decryption and Storing password, secretKey, IV and Hash in Shared Preferences
fun hashAndSavePasswordHash(context: Context, clearPassword: String) {
val digest = MessageDigest.getInstance("SHA-1")
val result = digest.digest(clearPassword.toByteArray(Charsets.UTF_8))
val sb = StringBuilder()
for (b in result) {
sb.append(String.format("%02X", b))
}
val hashedPassword = sb.toString()
val sharedPref = PreferenceManager.getDefaultSharedPreferences(context)
val editor = sharedPref.edit()
@reuniware
reuniware / netfiltertest01.py
Last active February 7, 2024 07:09
Python + Netfilterqueue + Scapy (trying to intercept HTTP traffic from Kali Linux)
# apt-get install build-essential python-dev libnetfilter-queue-dev
# pip install NetfilterQueue
# sudo apt-get install python-netfilterqueue
# iptables -F
# iptables -F -t nat
# iptables -I FORWARD -j NFQUEUE --queue-num 0
# arpspoof -i eth0 192.168.1.200 -t 192.168.1.1
# arpspoof -i eth0 192.168.1.1 -t 192.168.1.200
from netfilterqueue import NetfilterQueue
@reuniware
reuniware / pdfwriter.kt
Created January 10, 2020 13:53
(Android/Kotlin) Write unlimited number of lines to PDF (A4).
fun createAndWritePdf() {
initPdfDocument()
writeToPdfDocument("One line...")
writeToPdfDocument("Another line...")
closePdfDocument()
savePdfDocument()
}
lateinit var document : PdfDocument
@reuniware
reuniware / AESEncryptDecrypt.kt
Last active January 13, 2023 07:11
(Android/Kotlin) Encrypt and Decrypt with AES algorithm, and save/restore Secret Key and Inizialization Vector in SharedPreferences
fun encrypt(context:Context, strToEncrypt: String): ByteArray {
val plainText = strToEncrypt.toByteArray(Charsets.UTF_8)
val keygen = KeyGenerator.getInstance("AES")
keygen.init(256)
val key = keygen.generateKey()
saveSecretKey(context, key)
val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
cipher.init(Cipher.ENCRYPT_MODE, key)
val cipherText = cipher.doFinal(plainText)
@reuniware
reuniware / postvalue.kt
Created November 17, 2022 10:49
android mvvm livedata postvalue example
package com.example.myapplication
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
@reuniware
reuniware / mvvm_livedata.kt
Created November 17, 2022 10:20
Android Kotlin MVVM LiveData basic code
package com.example.myapplication
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
@reuniware
reuniware / downloadyoutubevideo.py
Created November 15, 2022 10:25
Download Youtube Video as MP3
from pytube import YouTube
import os
yt = YouTube('https://www.youtube.com/watch?v=PEnwXYJcSZc')
#yt.streams.get_audio_only().download()
video = yt.streams.filter(only_audio=True).first()
destination = '.'
@reuniware
reuniware / randomgen.py
Last active November 3, 2022 19:07
Random string generator and word search
import os
import random
import time
from datetime import datetime
def log_to_results(str_to_log):
fr = open("results.txt", "a")
fr.write(str_to_log + "\n")
fr.close()
@reuniware
reuniware / StatsActivity.kt
Created July 5, 2019 11:55
Kotlin Google Charts API easy and basic implementation
package com.activity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_statistiques.*
class StatsActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)