Standard library / crypto/rsa
crypto/rsa.PublicKey
Contains modulus N and public exponent E. Size and Equal support key inspection and comparison. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type PublicKey struct { N *big.Int // modulus E int // public exponent}Working Example
Example Snippetgo
package main
import ( "crypto/rand" "crypto/rsa" "fmt")
func main() { k := must(rsa.GenerateKey(rand.Reader, 2048)) var p rsa.PublicKey = k.PublicKey fmt.Println(p.Size() == 256)}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}