1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-03 07:36:23 -07:00

replace call to crypt_r() with crypt()

This commit is contained in:
Joshua Merrell 2014-12-23 02:22:25 -08:00
parent ac7ce8cff4
commit 0931f94c2f

View file

@ -1,9 +1,9 @@
package main
import (
"code.google.com/p/go.crypto/bcrypt"
"crypto/md5"
"crypto/sha1"
"code.google.com/p/go.crypto/bcrypt"
"fmt"
"io"
"math/rand"
@ -14,14 +14,15 @@ import (
"time"
"unsafe"
)
// #cgo LDFLAGS: -lcrypt -Wall
// #define _GNU_SOURCE
// #ifndef __FreeBSD__
// #include <crypt.h>
// #endif
// #include <stdlib.h>
import "C"
var (
crypt_data = C.struct_crypt_data{}
null_time, _ = time.Parse("2006-01-02 15:04:05", "0000-00-00 00:00:00")
)
@ -44,11 +45,10 @@ func benchmarkTimer(name string, given_time time.Time, starting bool) time.Time
}
}
func crypt(key, salt string) string {
ckey := C.CString(key)
csalt := C.CString(salt)
out := C.GoString(C.crypt_r(ckey,csalt,&crypt_data))
out := C.GoString(C.crypt(ckey, csalt))
C.free(unsafe.Pointer(ckey))
C.free(unsafe.Pointer(csalt))
return out
@ -223,12 +223,12 @@ func getFileExtension(filename string) string {
}
func getFormattedFilesize(size float32) string {
if(size < 1000) {
if size < 1000 {
return fmt.Sprintf("%fB", size)
} else if(size <= 100000) {
} else if size <= 100000 {
//size = size * 0.2
return fmt.Sprintf("%fKB", size/1024)
} else if(size <= 100000000) {
} else if size <= 100000000 {
//size = size * 0.2
return fmt.Sprintf("%fMB", size/1024/1024)
}