package ru.micord.ervu.account_applications.component.field.dataconvert;

import component.field.dataconvert.DataConverter;
import org.springframework.beans.factory.annotation.Autowired;
import ru.micord.ervu.account_applications.security.service.EncryptionService;

/**
 * @author Adel Kalimullin
 */
public class PasswordConverter implements DataConverter<String, String> {
  private final EncryptionService encryptionService;

  @Autowired
  public PasswordConverter(EncryptionService encryptionService) {
    this.encryptionService = encryptionService;
  }

  @Override
  public String convertValueForSave(String s) {
    return encryptionService.decrypt(s);
  }

  @Override
  public String convertValueForLoad(String s) {
    return s;
  }
}
