Skip to content

Instantly share code, notes, and snippets.

@DanielMorsing
Created April 19, 2015 10:37
Show Gist options
  • Save DanielMorsing/c7fc6d75929ff060b103 to your computer and use it in GitHub Desktop.
Save DanielMorsing/c7fc6d75929ff060b103 to your computer and use it in GitHub Desktop.
A shitty thing I did in order to pgp sign a tweet.
package main
import (
"fmt"
"io/ioutil"
"math/big"
"os"
)
func main() {
b, _ := ioutil.ReadAll(os.Stdin)
i := 0
j := len(b)-1
for j >= i {
b[i], b[j] = b[j], b[i]
i++
j--
}
var bi big.Int
bi.SetBytes(b)
blen := uint(bi.BitLen())
var x uint
xi := make([]rune, 0)
for i := uint(0); i < blen; i++ {
x = bi.Bit(int(i)) | (x << 1)
if (i%14) == 0 && i != 0 {
xi = append(xi, 0x20000+rune(x))
x = 0
}
}
if x != 0 {
xi = append(xi, 0x20000+rune(x))
}
fmt.Println(string(xi))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment