Enchantrix/examples/checksums/main.go
google-labs-jules[bot] 8082074054 docs: Add feature examples
Adds a comprehensive set of examples to demonstrate the library's features.

- Breaks out the existing `examples/main.go` into separate, well-named files.
- Adds new examples for hashing, checksums, RSA, and PGP.
- The PGP examples cover key generation, encryption/decryption, signing/verification, and symmetric encryption.
- Removes the old `examples/main.go` file and formats the new example files.
2025-11-13 19:37:35 +00:00

27 lines
838 B
Go

package main
import (
"fmt"
"github.com/Snider/Enchantrix/pkg/crypt"
)
func main() {
fmt.Println("--- Checksum Demo ---")
cryptService := crypt.NewService()
// Luhn
luhnPayloadGood := "49927398716"
luhnPayloadBad := "49927398717"
fmt.Printf("Luhn Checksum:\n")
fmt.Printf(" - Payload '%s' is valid: %v\n", luhnPayloadGood, cryptService.Luhn(luhnPayloadGood))
fmt.Printf(" - Payload '%s' is valid: %v\n", luhnPayloadBad, cryptService.Luhn(luhnPayloadBad))
// Fletcher
fletcherPayload := "abcde"
fmt.Printf("\nFletcher Checksums (Payload: \"%s\"):\n", fletcherPayload)
fmt.Printf(" - Fletcher16: %d\n", cryptService.Fletcher16(fletcherPayload))
fmt.Printf(" - Fletcher32: %d\n", cryptService.Fletcher32(fletcherPayload))
fmt.Printf(" - Fletcher64: %d\n", cryptService.Fletcher64(fletcherPayload))
fmt.Println()
}