Skip to content

Instantly share code, notes, and snippets.

View pseusys's full-sized avatar
🚀
Striving for better

Aleksandr Sergeev pseusys

🚀
Striving for better
View GitHub Profile
@pseusys
pseusys / cipher.py
Last active August 3, 2025 18:59
RSA-OAEP-CBC cipher example
from Crypto.Cipher import PKCS1_OAEP
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
def _xor_arrays(a1: bytes, a2: bytes) -> bytes:
return bytes([a ^ b for a, b in zip(a1, a2)])
class RSACipher:
@pseusys
pseusys / library.py
Last active March 12, 2023 22:15
Python external module finction patcher
def some_function(some_input: str) -> str:
return f"I return '{some_input}', processed in some old way..."
@pseusys
pseusys / ResultHolders.kt
Created February 24, 2022 12:27
Android activity and fragment, easily integrateable with permission requesting
import android.os.Bundle
import androidx.activity.result.*
import androidx.activity.result.contract.ActivityResultContract
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import java.lang.RuntimeException
import kotlin.reflect.KClass
/**
@pseusys
pseusys / range_by_characters.ts
Created February 24, 2022 12:21
TypeScript extension for JS browser libraries for measuring text ranges in nodes in characters
// If collected by WebPack, should be included once.
// We have to declare Range and Selection for this code not to break Node.js environment.
// We can extend basic types as far as no untrusted third-party libraries are included.
declare interface Range {
_set_range_in_node (node: HTMLElement, pos?: number);
_set_range_start_in_node (node: HTMLElement, pos: number);
_set_range_end_in_node (node: HTMLElement, pos: number);
_get_range_start_in_node (node: Node): NodeInfo | null;