コード例 #1
0
ファイル: EnvelopeService.cs プロジェクト: hotjk/dotconfig
        public static string PublicDecrypt(Envelope envelope, string publicKey)
        {
            RSAManager rsa = new RSAManager(publicKey);

            byte[]          key = rsa.PublicDecrypt(Convert.FromBase64String(envelope.Key));
            byte[]          iv  = rsa.PublicDecrypt(Convert.FromBase64String(envelope.IV));
            RijndaelManager aes = new RijndaelManager(key, iv);

            return(aes.Decrypt(envelope.Data));
        }
コード例 #2
0
ファイル: EnvelopeService.cs プロジェクト: hotjk/dotconfig
        public static Envelope PrivateEncrypt(string id, string source, string privateKey)
        {
            Envelope envelope = new Envelope {
                Id = id
            };

            byte[] key, iv;
            RijndaelManager.GenerateKeyAndIV(out key, out iv);
            RijndaelManager aes = new RijndaelManager(key, iv);

            envelope.Data = aes.Encrypt(source);

            RSAManager rsa = new RSAManager(privateKey);

            envelope.Key = Convert.ToBase64String(rsa.PrivateEncrypt(key));
            envelope.IV  = Convert.ToBase64String(rsa.PrivateEncrypt(iv));
            return(envelope);
        }