コード例 #1
0
        public static string Decrypt(byte[] cipherbytes, bool compress)
        {
            byte[] buffer = new byte[cipherbytes.Length - 1];
            int    index  = 0;

            for (int i = 1; i < cipherbytes.Length; i++)
            {
                buffer[index++] = cipherbytes[i];
            }

            string decrypted = Obviex.CipherLite.Rijndael.Decrypt(buffer, "this is a pass phrase", null, KEY_SIZE, PASSWORD_ITERATIONS, "this is a salt value", HASH_ALGORITHM);

            if (cipherbytes[0] == COMPRESSED)
            {
                return(CompressionHelper.Inflate(decrypted));
            }
            else
            {
                return(decrypted);
            }
        }
コード例 #2
0
 public static string Encrypt(string plaintext, bool compress)
 {
     return(CompressionHelper.BytesToString(Encrypt(CompressionHelper.StringToBytes(plaintext), compress)));
 }
コード例 #3
0
 public static string EncryptToBase64(string plaintext)
 {
     byte[] plainBytes  = CompressionHelper.StringToBytes(plaintext);
     byte[] cipherBytes = Encrypt(plainBytes);
     return(Convert.ToBase64String(cipherBytes));
 }
コード例 #4
0
 public static string Decrypt(string ciphertext, bool compress)
 {
     return(Decrypt(CompressionHelper.StringToBytes(ciphertext), compress));
 }