-
Notifications
You must be signed in to change notification settings - Fork 0
cnjax/hashids
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
//Test by your encrypt secure key.
package main
import (
"fmt"
"./hashids" // Import from your local directory
)
func main() {
// Test the same input as PHP: "2773"
encoded, err := hashids.EncodeID("2773", "Secure")
if err != nil {
fmt.Println("Encoding error:", err)
return
}
fmt.Println("Encoded:", encoded) // Should output "D9r4" to match PHP
// Test decoding
decoded, err := hashids.DecodeID(encoded, "Secure")
if err != nil {
fmt.Println("Decoding error:", err)
return
}
fmt.Println("Decoded:", decoded) // Should output "2773"
// Also test decoding the known PHP value
knownPHPOutput := "D9r4"
decodedPHP, err := hashids.DecodeID(knownPHPOutput, "Secure")
if err != nil {
fmt.Println("Decoding PHP output error:", err)
return
}
fmt.Println("Decoded PHP output:", decodedPHP)
}About
Compatible with php hashids in golang
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published