Beispiel #1
0
        internal string DecryptFromBase64String(string Source, string PrivateKey)
        {
            byte[] tempByte = System.Convert.FromBase64String(Source);
            RSACSP.FromXmlString(DESManager.DesDecrypt(PrivateKey));
            string result = Encoding.UTF8.GetString(RSACSP.Decrypt(tempByte, false));

            return(result);
        }
Beispiel #2
0
        internal string EncryptToBase64String(string Source, string PublicKey)
        {
            RSACSP.FromXmlString(DESManager.DesDecrypt(PublicKey));
            byte[] tempByte = EncryptToByte(Source, PublicKey);
            string result   = Convert.ToBase64String(tempByte);

            return(result);
        }
Beispiel #3
0
        internal string Encrypt(string Source, string PublicKey)
        {
            RSACSP.FromXmlString(DESManager.DesDecrypt(PublicKey));
            byte[]        tempByte = EncryptToByte(Source, PublicKey);
            StringBuilder sb       = new StringBuilder();

            foreach (byte b in tempByte)
            {
                sb.Append(b.ToString().PadLeft(3, '0'));
            }
            return(sb.ToString());
        }
Beispiel #4
0
        internal string Decrypt(string Source, string PrivateKey)
        {
            int ByteNum = Source.Length / 3;

            byte[]        tempByte = new byte[ByteNum];
            StringBuilder sb       = new StringBuilder();

            try
            {
                for (int i = 0; i < ByteNum; i++)
                {
                    tempByte[i] = Convert.ToByte(Source.Substring(i * 3, 3), 10);
                }
            }
            catch
            {
                throw new Exception("密文内容有误");
            }
            RSACSP.FromXmlString(DESManager.DesDecrypt(PrivateKey));
            string result = Encoding.UTF8.GetString(RSACSP.Decrypt(tempByte, false));

            return(result);
        }
Beispiel #5
0
 internal byte[] EncryptToByte(string Source, string PublicKey)
 {
     RSACSP.FromXmlString(DESManager.DesDecrypt(PublicKey));
     return(RSACSP.Encrypt(Encoding.UTF8.GetBytes(Source), false));
 }