number

package
v0.0.0-...-909cd7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coprime

func Coprime(N int, seed ...[32]byte) (int, error)

Coprime returns a random coprime number in [2, N).

Example
package main

import (
	"fmt"

	"github.com/itsubaki/rsa/number"
)

func main() {
	p, err := number.Coprime(15)
	if err != nil {
		panic(err)
	}

	for _, e := range []int{2, 4, 7, 8, 11, 13, 14} {
		if p == e {
			fmt.Println("found")
			break
		}
	}

}
Output:

found

func Euler

func Euler(p, q int) int

Euler returns the Euler's function. p and q must be prime numbers.

Example
package main

import (
	"fmt"

	"github.com/itsubaki/rsa/number"
)

func main() {
	e := number.Euler(17, 19)
	fmt.Println(e)

}
Output:

288

func GCD

func GCD(a, b int) int

GCD returns the greatest common divisor of a and b.

Example
package main

import (
	"fmt"

	"github.com/itsubaki/rsa/number"
)

func main() {
	gcd := number.GCD(15, 7)
	fmt.Println(gcd)

}
Output:

1

func IsPrime

func IsPrime(N int) bool

IsPrime returns true if N is prime number.

func NewSource

func NewSource(seed ...[32]byte) (randv2.Source, error)

func Read

func Read() ([32]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL