Skip to content

Instantly share code, notes, and snippets.

@RIGIK93
RIGIK93 / gcd.rs
Last active June 11, 2023 01:24
Euclidean algorithm for computing greatest common divisor in rust
use num::traits::{Zero, Rem};
fn gcd<T>(a: T, b: T) -> T
where
T: Zero + Rem<Output = T> + std::cmp::PartialEq + Copy,
{
if b == T::zero() {
return a;
}
gcd(b, a % b)
@prologic
prologic / LearnGoIn5mins.md
Last active July 3, 2024 04:05
Learn Go in ~5mins
@sohamkamani
sohamkamani / rsa.go
Created April 12, 2020 17:31
Example of RSA encryption, decryption, signing, and verification in Go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
)