bf851bd9fc
Added support for dyntmpl to the template system. The Account Dashboard now sort of uses dyntmpl, more work needed here. Renamed the pre_render_view_topic hook to pre_render_topic. Added the GetCurrentLangPack() function. Added the alerts_no_new_alerts phrase. Added the account_level_list phrase. Refactored the route rename logic in the patcher to cut down on the amount of boilerplate. Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
28 lines
740 B
Go
28 lines
740 B
Go
package install
|
|
|
|
import "encoding/base64"
|
|
import "crypto/rand"
|
|
import "golang.org/x/crypto/bcrypt"
|
|
|
|
const saltLength int = 32
|
|
|
|
// Generate a cryptographically secure set of random bytes..
|
|
func GenerateSafeString(length int) (string, error) {
|
|
rb := make([]byte, length)
|
|
_, err := rand.Read(rb)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return base64.StdEncoding.EncodeToString(rb), nil
|
|
}
|
|
|
|
// Generate a bcrypt hash
|
|
// Note: The salt is in the hash, therefore the salt value is blank
|
|
func BcryptGeneratePassword(password string) (hash string, salt string, err error) {
|
|
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
|
if err != nil {
|
|
return "", "", err
|
|
}
|
|
return string(hashedPassword), salt, nil
|
|
}
|