(body share.CreateBody)
| 238 | }) |
| 239 | |
| 240 | func getSharePasswordHash(body share.CreateBody) (data []byte, statuscode int, err error) { |
| 241 | if body.Password == "" { |
| 242 | return nil, 0, nil |
| 243 | } |
| 244 | |
| 245 | hash, err := bcrypt.GenerateFromPassword([]byte(body.Password), bcrypt.DefaultCost) |
| 246 | if err != nil { |
| 247 | return nil, http.StatusInternalServerError, fmt.Errorf("failed to hash password: %w", err) |
| 248 | } |
| 249 | |
| 250 | return hash, 0, nil |
| 251 | } |