Last active
August 29, 2015 13:58
-
-
Save oal/10017960 to your computer and use it in GitHub Desktop.
Crypt binding for Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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