Exemplo n.º 1
0
        public async Task <byte[]> DecipherMessage(string ct, SerializedPrivateKey sKey)
        {
            var decipherTask = Task <byte[]> .Factory.StartNew(() =>
            {
                BFUserPrivateKey key       = new BFUserPrivateKey(sKey);
                SerializedBFCText ciphered = (SerializedBFCText)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(ct), typeof(SerializedBFCText));
                BFCText cText = new BFCText(ciphered);
                return(BFCipher.decrypt(cText, key));
            });

            await decipherTask;

            return((byte[])decipherTask.Result);
        }
Exemplo n.º 2
0
        public async Task <string> DecipherText(string ct, SerializedPrivateKey sKey)
        {
            var decipherTask = Task <byte[]> .Factory.StartNew(() =>
            {
                BFUserPrivateKey key       = new BFUserPrivateKey(sKey);
                SerializedBFCText ciphered = (SerializedBFCText)JsonConvert.DeserializeObject(ct, typeof(SerializedBFCText));
                BFCText cText = new BFCText(ciphered);
                return(BFCipher.decrypt(cText, key));
            });

            await decipherTask;

            byte[] bMessage = (byte[])decipherTask.Result;
            return(Encoding.UTF8.GetString(bMessage, 0, bMessage.Length));
        }