public void TestEncryptionUtilCanProcessEmptyString()
    {
      var login = "";

      EncryptionUtil encryptor = new EncryptionUtil(this.publicCertificate);
      string encryptedLogin = encryptor.Encrypt(login);

      Assert.AreEqual(login, this.Decrypt(encryptedLogin));
    }
    public void TestValidEncryptDecrypt()
    {
      var login = "******";

      EncryptionUtil encryptor = new EncryptionUtil(this.publicCertificate);
      string encryptedLogin = encryptor.Encrypt(login);

      Assert.AreEqual(login, this.Decrypt(encryptedLogin));
    }
    public void TestCertificatesBigIntegers()
    {
      EncryptionUtil publicEcnryptor = new EncryptionUtil(this.publicCertificate);

      BigInteger publicModulusInteger = publicEcnryptor.BigIntegerForModulus();
      BigInteger publicExponentInteger = publicEcnryptor.BigIntegerForExponent();

      EncryptionUtil privateEcnryptor = new EncryptionUtil(this.privateCertificate);

      BigInteger privateModulusInteger = privateEcnryptor.BigIntegerForModulus();
      BigInteger privateExponentInteger = privateEcnryptor.BigIntegerForExponent();

      Assert.AreEqual(true, publicModulusInteger.Equals(privateModulusInteger));
      Assert.AreEqual(true, publicExponentInteger.Equals(privateExponentInteger));
    }
    public HttpRequestMessage AddEncryptedCredentialHeaders(HttpRequestMessage httpRequest)
    {
      #if !ENCRYPTION_DISABLED
      EncryptionUtil cryptor = new EncryptionUtil(this.certificate);
      var encryptedLogin = cryptor.Encrypt(this.login);
      var encryptedPassword = cryptor.Encrypt(this.password);
      #else
      var encryptedLogin = this.login;
      var encryptedPassword = this.password;
      #endif

      httpRequest.Headers.Add("X-Scitemwebapi-Username", encryptedLogin);
      httpRequest.Headers.Add("X-Scitemwebapi-Password", encryptedPassword);

      #if !ENCRYPTION_DISABLED
      httpRequest.Headers.Add("X-Scitemwebapi-Encrypted", "1");
      #endif

      return httpRequest;
    }
    public void TestEncryptionUtilReturnsNullForNullInput()
    {
      EncryptionUtil encryptor = new EncryptionUtil(this.publicCertificate);
      string encryptedLogin = encryptor.Encrypt(null);

      Assert.IsNull(encryptedLogin);
    }