Skip to content

Instantly share code, notes, and snippets.

@Caaz
Created September 5, 2017 00:23
Show Gist options
  • Save Caaz/dad28c14ed3f3f9e465aa6af0423e579 to your computer and use it in GitHub Desktop.
Save Caaz/dad28c14ed3f3f9e465aa6af0423e579 to your computer and use it in GitHub Desktop.
Shit of base64 integer conversions
package main
import (
"fmt"
)
func main() {
fmt.Println(i_to_base64(500))
}
func i_to_base64(num int) string {
b64 := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
base := len(b64)
str := ""
for num > 0 {
r := num % base
num -= r
num /= base
str = string(b64[r]) + str
}
return str
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment