private string SerializeCaptchaValue(CaptchaValue value) { using (var ms = new MemoryStream()) { new BinaryFormatter().Serialize(ms, value); return(Convert.ToBase64String(ms.ToArray())); } }
public Captcha CreateNewCaptcha(int length) { var captchaValue = new CaptchaValue() { Value = this.GenerateRandomString(length), LastTimeAttempted = DateTime.Now, FirstTimeAttempted = DateTime.Now, NumberOfTimesAttempted = 0 }; var captcha = new Captcha() { ValueString = this.SerializeCaptchaValue(captchaValue) }; return(captcha); }