简体   繁体   English

如何读取加密文本文件中的行数?

[英]How do i read the numbers of lines on a encrypted text file?

So i have this encrypt text files program (which works as desired), the problem is that i need to display this result on a MessageBox: 所以我有这个加密文本文件程序(按需要工作),问题是我需要在MessageBox上显示这个结果:

The numbers of lines readed BEFORE encrypting and AFTER the files is encrypted.... 在加密之前和文件加密之后加入的行数....

the line-counter for the lines readed before encrypting already works WITH the same algorithm 在加密之前已经处理的行的行计数器已经使用相同的算法

Ej. EJ。 'X' numbers of lines readed 'Y' numbers of line are encrypted. 'X'行的行数'Y'行加密。

i have this simple algorithm to read the encrypted file: 我有这个简单的算法来读取加密文件:

    public long CountlLines(string a)
    {
        long count = 0;
        string line;

        FileStream FS = new FileStream(a, FileMode.Open, FileAccess.Read);
        StreamReader Reader = new StreamReader(FS);

        while (Reader.EndOfStream == false)
        {
            line = Reader.ReadLine();
            count++;
        }


        Reader.Close();
        return count;
    }

i got this 159 lines files that, when decrypted, produces 11 lines of encrypted code (opened on notepad), but with this algorithm i got: 我得到了159行文件,当解密时,产生11行加密代码(在记事本上打开),但是使用这个算法,我得到了:

Ej. EJ。 '159' numbers of lines readed '1' numbers of line are encrypted. “159”行数加“1”行加密。

The encryption method is AES, with a 128-bits key...(in case of...). 加密方法是AES,具有128位密钥...(在......的情况下)。 Am i doing something wrong? 难道我做错了什么? or is there some kind of specific method or 'way' to read encrypted text? 或者是否有某种特定方法或“方式”来读取加密文本? Thanks. 谢谢。

Your encrypted file contains no newline markers. 您的加密文件不包含换行标记。 Thus when your "Reader.ReadLine()" executes, it does what you asked it to. 因此,当您的“Reader.ReadLine()”执行时,它会按照您的要求执行操作。 It reads the lines until it comes to a newline, which there arent any of, because you have encrypted them all. 它会读取这些行,直到它出现在换行符中,因为你已经加密了所有行。 Its all one line now. 它现在都是一条线。

Assuming of course you have encrypted the entire contents, and not line by line ;) 假设你当然加密了整个内容,而不是逐行加密;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM