Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
@cicorias
cicorias / .gitattributes
Last active January 5, 2022 14:09 — forked from hughbiquitous/.gitignore
.gitignore for Java/IntelliJ/gradle
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
@cicorias
cicorias / modsqrt.py
Last active December 14, 2021 01:41 — forked from nakov/modsqrt.py
mod_sqrt - Python 3 implementation
def modular_sqrt(a, p):
def legendre_symbol(a, p):
""" Compute the Legendre symbol a|p using
Euler's criterion. p is a prime, a is
relatively prime to p (if p divides
a, then a|p = 0)
Returns 1 if a has a square root modulo
p, -1 otherwise.
@cicorias
cicorias / ecc.py
Created December 12, 2021 02:16 — forked from bellbind/ecc.py
[python]basics of elliptic curve cryptography
# Basics of Elliptic Curve Cryptography implementation on Python
import collections
def inv(n, q):
"""div on PN modulo a/b mod q as a * inv(b, q) mod q
>>> assert n * inv(n, q) % q == 1
"""
for i in range(q):
if (n * i) % q == 1:
@cicorias
cicorias / rsa.py
Created October 26, 2021 20:59 — forked from djego/rsa.py
A simple RSA implementation in Python
'''
620031587
Net-Centric Computing Assignment
Part A - RSA Encryption
'''
import random
'''
@cicorias
cicorias / modinverse.py
Created October 25, 2021 19:56 — forked from ofaurax/modinverse.py
Modular Inverse for RSA in python
#!/usr/bin/env python3
p = 61
q = 53
n = p*q
phi = (p-1)*(q-1)
# Took from SO
def egcd(a, b):
@cicorias
cicorias / JavaIntToLittleEndianUnsigned
Last active October 25, 2021 03:00 — forked from paulononaka/JavaIntToLittleEndianUnsigned
Convert a Int (in Java, big endian signed) to LittleEndian unsigned
private static byte[] intToLittleEndian(long numero) {
ByteBuffer bb = ByteBuffer.allocate(4);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt((int) numero);
return bb.array();
}
// OR ...
private static byte[] intToLittleEndian(long numero) {
@cicorias
cicorias / load_dotenv.sh
Last active February 15, 2022 14:56 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# or
set -o allexport
source .env
@cicorias
cicorias / deployment.yaml
Created August 5, 2021 00:01 — forked from erikaulin/deployment.yaml
Kubernetes kuard deployment
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: kuard-deployment
labels:
app: kuard
spec:
replicas: 3
selector:
matchLabels:
- task: Kubernetes@1
name: 'apply'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'test'
namespace: 'default'
command: 'apply'
arguments: '-f deployment.yaml'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
@cicorias
cicorias / retry.py
Created April 30, 2021 12:20 — forked from FBosler/retry.py
retry.py
#Copyright 2021 Fabian Bosler
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.