mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-15 00:31:30 -05:00
Bumps [github.com/kovidgoyal/imaging](https://github.com/kovidgoyal/imaging) from 1.7.2 to 1.8.17. - [Release notes](https://github.com/kovidgoyal/imaging/releases) - [Changelog](https://github.com/kovidgoyal/imaging/blob/master/.goreleaser.yaml) - [Commits](https://github.com/kovidgoyal/imaging/compare/v1.7.2...v1.8.17) --- updated-dependencies: - dependency-name: github.com/kovidgoyal/imaging dependency-version: 1.8.17 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
36 lines
879 B
Go
36 lines
879 B
Go
package shm
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base32"
|
|
"fmt"
|
|
not_rand "math/rand/v2"
|
|
"strconv"
|
|
"unsafe"
|
|
)
|
|
|
|
var _ = fmt.Print
|
|
|
|
func RandomFilename() string {
|
|
b := []byte{0, 0, 0, 0, 0, 0, 0, 0}
|
|
_, err := rand.Read(b)
|
|
if err != nil {
|
|
return strconv.FormatUint(uint64(not_rand.Uint32()), 16)
|
|
}
|
|
return base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(b)
|
|
}
|
|
|
|
// Unsafely converts s into a byte slice.
|
|
// If you modify b, then s will also be modified. This violates the
|
|
// property that strings are immutable.
|
|
func UnsafeStringToBytes(s string) (b []byte) {
|
|
return unsafe.Slice(unsafe.StringData(s), len(s))
|
|
}
|
|
|
|
// Unsafely converts b into a string.
|
|
// If you modify b, then s will also be modified. This violates the
|
|
// property that strings are immutable.
|
|
func UnsafeBytesToString(b []byte) (s string) {
|
|
return unsafe.String(unsafe.SliceData(b), len(b))
|
|
}
|