Esempio n. 1
0
        public string Encrypt(HttpPostedFileBase file)
        {
            var txt = CryptoLogic.GetTxtFromFile(file, true);

            return(CryptoHelper.Encrypt(txt, _testRecipient,
                                        CryptoLogic.KeyCollection[CryptoLogic.PUBLIC]));
        }
Esempio n. 2
0
        public string Decrypt(HttpPostedFileBase file)
        {
            var encryptedText = CryptoLogic.GetTxtFromFile(file);
            var password      = Encoding.UTF8.GetString(CryptoLogic.KeyCollection[CryptoLogic.SECRET]);

            return(CryptoHelper.Decrypt(encryptedText, password));
        }
Esempio n. 3
0
        public void Sign(HttpPostedFileBase file)
        {
            var data             = CryptoLogic.GetBytesFromFile(file);
            var digitalSignature = _signer.Sign(data, CryptoLogic.KeyCollection[CryptoLogic.PRIVATE]);

            File.WriteAllBytes(CryptoLogic.SignatureFileName, digitalSignature);
        }
Esempio n. 4
0
        public string Decrypt(HttpPostedFileBase file)
        {
            VirgilCipher vc            = new VirgilCipher();
            var          encryptedText = CryptoLogic.GetTxtFromFile(file);

            return(CryptoHelper.Decrypt(encryptedText, _testRecipient,
                                        CryptoLogic.KeyCollection[CryptoLogic.PRIVATE]));
        }
Esempio n. 5
0
        public bool Verify(HttpPostedFileBase file)
        {
            var rawData    = File.ReadAllBytes(CryptoLogic.PlainTxtFile);
            var signedData = CryptoLogic.GetBytesFromFile(file);
            var isVerified = _signer.Verify(rawData, signedData, CryptoLogic.KeyCollection[CryptoLogic.PUBLIC]);

            return(isVerified);
        }