Skip to content

Instantly share code, notes, and snippets.

@oal
Last active August 29, 2015 13:58
Show Gist options
  • Save oal/10017960 to your computer and use it in GitHub Desktop.
Save oal/10017960 to your computer and use it in GitHub Desktop.
Crypt binding for Go
package crypt
// #cgo LDFLAGS: -lcrypt
// #include <stdlib.h>
// #include <crypt.h>
import "C"
import "unsafe"
func Crypt(key, salt string) string {
cKey := C.CString(key)
defer C.free(unsafe.Pointer(cKey))
cSalt := C.CString(salt)
defer C.free(unsafe.Pointer(cSalt))
return C.GoString(C.crypt(cKey, cSalt))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment