Ejemplo n.º 1
0
 public static string Decrypt(string Key, string Iv, CipherMode Mode, PaddingMode Padding, string Encrypted, ByteEncodeMethod ByteEncode, Encoding TextEncode)
 {
     byte[] encrypted = ByteArrayEncoder.Decode(Encrypted, ByteEncode);
     byte[] key       = ByteArrayEncoder.Decode(Key, ByteEncode);
     byte[] iv        = ByteArrayEncoder.Decode(Iv, ByteEncode);
     byte[] bytes     = AesWrapper.Decrypt(key, iv, Mode, Padding, encrypted);
     return(TextEncode.GetString(bytes));
 }
Ejemplo n.º 2
0
        public static string Decrypt(RSAKeyEncoded encodedKey, string encryptedText, ByteEncodeMethod ByteEncode, Encoding TextEncode)
        {
            RSAParameters key = encodedKey.ToRSAParameters();

            byte[] encryptedText2 = ByteArrayEncoder.Decode(encryptedText, ByteEncode);
            byte[] bytes          = RSASimpleWrapper.Decrypt(key, encryptedText2);
            return(TextEncode.GetString(bytes));
        }
Ejemplo n.º 3
0
 public static string Encrypt(string Key, string Iv, CipherMode Mode, PaddingMode Padding, string Plain, ByteEncodeMethod ByteEncode, Encoding TextEncode)
 {
     byte[] bytes     = TextEncode.GetBytes(Plain);
     byte[] key       = ByteArrayEncoder.Decode(Key, ByteEncode);
     byte[] iv        = ByteArrayEncoder.Decode(Iv, ByteEncode);
     byte[] byteArray = AesWrapper.Encrypt(key, iv, Mode, Padding, bytes);
     return(ByteArrayEncoder.Encode(byteArray, ByteEncode));
 }
Ejemplo n.º 4
0
        public RSAParameters ToRSAParameters(ByteEncodeMethod byteEncodeMethod)
        {
            RSAParameters result = default(RSAParameters);

            if (!string.IsNullOrEmpty(this.D))
            {
                result.D = ByteArrayEncoder.Decode(this.D, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.DP))
            {
                result.DP = ByteArrayEncoder.Decode(this.DP, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.DQ))
            {
                result.DQ = ByteArrayEncoder.Decode(this.DQ, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.Exponent))
            {
                result.Exponent = ByteArrayEncoder.Decode(this.Exponent, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.InverseQ))
            {
                result.InverseQ = ByteArrayEncoder.Decode(this.InverseQ, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.Modulus))
            {
                result.Modulus = ByteArrayEncoder.Decode(this.Modulus, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.P))
            {
                result.P = ByteArrayEncoder.Decode(this.P, byteEncodeMethod);
            }
            if (!string.IsNullOrEmpty(this.Q))
            {
                result.Q = ByteArrayEncoder.Decode(this.Q, byteEncodeMethod);
            }
            return(result);
        }