https://github.com/kechako/scramble
scramble is a Go library that performs format-preserving scrambling and unscrambling of numeric values using the FF1 FPE algorithm.
https://github.com/kechako/scramble
ff1 fpe go golang scramble
Last synced: 5 months ago
JSON representation
scramble is a Go library that performs format-preserving scrambling and unscrambling of numeric values using the FF1 FPE algorithm.
- Host: GitHub
- URL: https://github.com/kechako/scramble
- Owner: kechako
- License: mit
- Created: 2018-06-13T11:45:58.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-12-11T09:31:39.000Z (6 months ago)
- Last Synced: 2026-01-11T11:33:17.905Z (5 months ago)
- Topics: ff1, fpe, go, golang, scramble
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scramble
[](https://godoc.org/github.com/kechako/scramble/v2)
scramble is a Go library that performs format-preserving scrambling and unscrambling of numeric values using the FF1 FPE algorithm.
It provides simple APIs that take and return uint32 or uint64, enabling reversible obfuscation while preserving the original numeric format.
This makes it well suited for anonymization, tokenization, and other use cases where fixed-size numeric identifiers must remain valid.
## Installation
```console
go get github.com/kechako/scramble/v2
```
## Usage
```golang
package main
import (
"fmt"
"log"
scramble "github.com/kechako/scramble/v2"
)
func main() {
// Generate a random key
key, err := scramble.GenerateKey(16)
if err != nil {
log.Fatal(err)
}
// Create a scrambler for uint32 using the generated key
s, err := scramble.NewScrambler[uint32](key)
if err != nil {
log.Fatal(err)
}
scrambled, err := s.Scramble(1234)
if err != nil {
log.Fatal(err)
}
fmt.Println(scrambled)
// e.g. 4085920800
unscrambled, err := s.Unscramble(scrambled)
if err != nil {
log.Fatal(err)
}
fmt.Println(unscrambled)
// 1234
}
```