protected internal void ComputeEncryptionKeyFingerprintWhenNeeded()
 {
     try
     {
         if (_encryptionCertificate == null || !string.IsNullOrEmpty(_encryptionKeyFingerprint))
         {
             // No encryption certificate set or certificate fingerprint already provided
             return;
         }
         var encodedKey          = RsaKeyUtils.GetEncoded(_encryptionCertificate.PublicKey);
         var keyFingerprintBytes = Sha256Digest(encodedKey);
         _encryptionKeyFingerprint = EncodingUtils.HexEncode(keyFingerprintBytes);
     }
     catch (Exception e)
     {
         throw new EncryptionException("Failed to compute encryption key fingerprint!", e);
     }
 }
Пример #2
0
 public void TestHexEncode_ShouldThrowArgumentNullException_WhenNullValue()
 {
     EncodingUtils.HexEncode(null);
 }
Пример #3
0
        public void TestHexEncode_ShouldKeepLeadingZeros()
        {
            var hex = EncodingUtils.HexEncode(SHA256.Create().ComputeHash(Encoding.ASCII.GetBytes("WIDDIES")));

            Assert.AreEqual("000000c71f1bda5b63f5165243e10394bc9ebf62e394ef7c6e049c920ea1b181", hex);
        }
Пример #4
0
 public void TestHexEncode()
 {
     Assert.AreEqual("00", EncodingUtils.HexEncode(new byte[1]));
     Assert.AreEqual("736f6d652064617461", EncodingUtils.HexEncode(Encoding.ASCII.GetBytes("some data")));
     Assert.AreEqual("", EncodingUtils.HexEncode(Encoding.ASCII.GetBytes("")));
 }