mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-05 08:46:23 -07:00
replace call to crypt_r() with crypt()
This commit is contained in:
parent
ac7ce8cff4
commit
0931f94c2f
1 changed files with 30 additions and 30 deletions
16
src/util.go
16
src/util.go
|
@ -1,9 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.google.com/p/go.crypto/bcrypt"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"code.google.com/p/go.crypto/bcrypt"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -14,14 +14,15 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #cgo LDFLAGS: -lcrypt -Wall
|
// #cgo LDFLAGS: -lcrypt -Wall
|
||||||
// #define _GNU_SOURCE
|
// #ifndef __FreeBSD__
|
||||||
// #include <crypt.h>
|
// #include <crypt.h>
|
||||||
|
// #endif
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
crypt_data = C.struct_crypt_data{}
|
|
||||||
null_time, _ = time.Parse("2006-01-02 15:04:05", "0000-00-00 00:00:00")
|
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 {
|
func crypt(key, salt string) string {
|
||||||
ckey := C.CString(key)
|
ckey := C.CString(key)
|
||||||
csalt := C.CString(salt)
|
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(ckey))
|
||||||
C.free(unsafe.Pointer(csalt))
|
C.free(unsafe.Pointer(csalt))
|
||||||
return out
|
return out
|
||||||
|
@ -223,12 +223,12 @@ func getFileExtension(filename string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFormattedFilesize(size float32) string {
|
func getFormattedFilesize(size float32) string {
|
||||||
if(size < 1000) {
|
if size < 1000 {
|
||||||
return fmt.Sprintf("%fB", size)
|
return fmt.Sprintf("%fB", size)
|
||||||
} else if(size <= 100000) {
|
} else if size <= 100000 {
|
||||||
//size = size * 0.2
|
//size = size * 0.2
|
||||||
return fmt.Sprintf("%fKB", size/1024)
|
return fmt.Sprintf("%fKB", size/1024)
|
||||||
} else if(size <= 100000000) {
|
} else if size <= 100000000 {
|
||||||
//size = size * 0.2
|
//size = size * 0.2
|
||||||
return fmt.Sprintf("%fMB", size/1024/1024)
|
return fmt.Sprintf("%fMB", size/1024/1024)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue