func EncryptPasswordObject(ctx context.Context, password string) (*primitive.UserPassword, *primitive.MasterKey, error) {
	pw := &primitive.UserPassword{
		Alg: Scrypt,
	}

	// Generate 128 bit (16 byte) salt for password
	salt := make([]byte, saltBytes) // 16
	_, err := rand.Read(salt)
	if err != nil {
		return nil, nil, err
	}

	// Encode salt bytes to base64url
	pw.Salt = base64.RawURLEncoding.EncodeToString(salt)

	// Create password hash bytes
	pwh, err := derivePassword(ctx, []byte(password), pw.Salt)
	if err != nil {
		return nil, nil, err
	}

	// Encode password value to base64url
	pw.Value = base64url.NewValue(pwh)

	m, err := CreateMasterKeyObject(ctx, []byte(password))
	if err != nil {
		return nil, nil, err
	}

	return pw, m, nil
}
// EncryptPasswordObject derives the master key and password hash from password
// and salt, returning the master and password objects
EncryptPasswordObject derives the master key and password hash from password
and salt, returning the master and password objects
// EncryptPasswordObject derives the master key and password hash from password // and salt returning the master and password objects
func EncryptPasswordObject(ctx context.Context, password string) (*primitive.UserPassword, *primitive.MasterKey, error) {
	pw := &primitive.UserPassword{
		Alg: Scrypt,
	}
	salt := make([]byte, saltBytes) 
	_, err := rand.Read(salt)
	if err != nil {
		return nil, nil, err
	}
	pw.Salt = base64.RawURLEncoding.EncodeToString(salt)
	pwh, err := derivePassword(ctx, []byte(password), pw.Salt)
	if err != nil {
		return nil, nil, err
	}
	pw.Value = base64url.NewValue(pwh)
	m, err := CreateMasterKeyObject(ctx, []byte(password))
	if err != nil {
		return nil, nil, err
	}
	return pw, m, nil
}
func EncryptPasswordObject ( ctx context . Context , password string ) ( * primitive . UserPassword , * primitive . MasterKey , error ) { pw := & primitive . UserPassword { Alg : Scrypt , } salt := make ( [ ] byte , saltBytes ) _ , err := rand . Read ( salt ) if err != nil { return nil , nil , err } pw . Salt = base64 . RawURLEncoding . EncodeToString ( salt ) pwh , err := derivePassword ( ctx , [ ] byte ( password ) , pw . Salt ) if err != nil { return nil , nil , err } pw . Value = base64url . NewValue ( pwh ) m , err := CreateMasterKeyObject ( ctx , [ ] byte ( password ) ) if err != nil { return nil , nil , err } return pw , m , nil }
EncryptPasswordObject derives the master key and password hash from password
and salt, returning the master and password objects
EncryptPasswordObject derives the master key and password hash from password and salt returning the master and password objects
// Generate 128 bit (16 byte) salt for password // 16 // Encode salt bytes to base64url // Create password hash bytes // Encode password value to base64url