Exemplo n.º 1
0
 public void FromRSAParameters(RSAParameters param, ByteEncodeMethod byteEncodeMethod)
 {
     if (param.D != null)
     {
         this.D = ByteArrayEncoder.Encode(param.D, byteEncodeMethod);
     }
     if (param.DP != null)
     {
         this.DP = ByteArrayEncoder.Encode(param.DP, byteEncodeMethod);
     }
     if (param.DQ != null)
     {
         this.DQ = ByteArrayEncoder.Encode(param.DQ, byteEncodeMethod);
     }
     if (param.Exponent != null)
     {
         this.Exponent = ByteArrayEncoder.Encode(param.Exponent, byteEncodeMethod);
     }
     if (param.InverseQ != null)
     {
         this.InverseQ = ByteArrayEncoder.Encode(param.InverseQ, byteEncodeMethod);
     }
     if (param.Modulus != null)
     {
         this.Modulus = ByteArrayEncoder.Encode(param.Modulus, byteEncodeMethod);
     }
     if (param.P != null)
     {
         this.P = ByteArrayEncoder.Encode(param.P, byteEncodeMethod);
     }
     if (param.Q != null)
     {
         this.Q = ByteArrayEncoder.Encode(param.Q, byteEncodeMethod);
     }
 }
Exemplo n.º 2
0
        public static string Encrypt(RSAKeyEncoded encodedKey, string plainText, ByteEncodeMethod ByteEncode, Encoding TextEncode)
        {
            RSAParameters key = encodedKey.ToRSAParameters();

            byte[] bytes     = TextEncode.GetBytes(plainText);
            byte[] byteArray = RSASimpleWrapper.Encrypt(key, bytes);
            return(ByteArrayEncoder.Encode(byteArray, ByteEncode));
        }
Exemplo 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));
 }