Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cnjax/hashids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

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

No packages published

Languages