No Description

PasswordPrompt.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace BulkPrinting
  11. {
  12. public partial class PasswordPrompt : Form
  13. {
  14. public PasswordPrompt()
  15. {
  16. InitializeComponent();
  17. }
  18. public string EncryptedVoucherPIN;
  19. private void btnVerify_Click(object sender, EventArgs e)
  20. {
  21. byte[] userKey;
  22. byte[] UnencryptedVoucherKey;
  23. using (var derivedBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(
  24. txtPassword.Text + "shie5heeX6pekaehovuS2yu0Ciejah7a",
  25. Globals.SessionSalt,
  26. Globals.SessionIterations))
  27. {
  28. userKey = derivedBytes.GetBytes(32);
  29. }
  30. try
  31. {
  32. UnencryptedVoucherKey = Utility.AesDecryptBytes(Globals.SessionData.Credentials.Payload.EncryptedVoucherKey, userKey);
  33. }
  34. catch (Exception)
  35. {
  36. MessageBox.Show("Password error. Logging out.", "Password error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  37. Utility.Logout();
  38. return;
  39. }
  40. if (UnencryptedVoucherKey.SequenceEqual(Globals.SessionVoucherKey)) {
  41. this.Hide();
  42. MessageBox.Show(Utility.TripleDESDecrypt(EncryptedVoucherPIN, UnencryptedVoucherKey).ToString());
  43. this.Close();
  44. }
  45. else {
  46. MessageBox.Show("Password error. Logging out.", "Password error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  47. Utility.Logout();
  48. }
  49. }
  50. }
  51. }