二进制安全

有很多函数都说明是二进制安全的,那么什么是二进制安全的呢?


  在网上搜索了一下,有一种说法是:


  【TechTarget中国原创】二进制安全功能(binary-safe function)是指在一个二进制文件上所执行的不更改文件内容的功能或者操作。这能够保证文件不会因为某些操作而遭到损坏。二进制数据是按照一串0和1的形式编码的。而绝大多数的程序会给某些特殊的比特串赋予不同的格式代码,所以当用户使用一个程序读取一个二进制文件时,该文件会被按照这个程序的规则进行解释。如果这个程序所使用的格式编码和文件被写入的格式编码一致,那么这个文件可以被正常读取,否则该文件的格式代码之中会被附加一些无意义的符号,也可能会导致文件损坏。如果最严重的情况发生,这样的操作会因为损坏导致你的数据永久丢失。所以你应该将重要的文件保存在只读性的存储介质上,例如光盘。


  还有人说是此乃密码学范畴——二进制安全是指,在传输数据时,保证二进制数据的信息安全,也就是不被篡改、破译等,如果被攻击,能够及时检测出来。 二进制安全包含了密码学的一些东西,比如加解密、签名等。


  但是个人直觉是关于数据存取的。


  在维基百科上搜索了一下:


  Binary-safe is a computer programming term mainly used in connection with string manipulating functions. A binary-safe function is essentially one that treats its input as a raw stream of data without any specific format. It should thus work with all 256 possible values that a character can take (assuming 8-bit characters).


  二进制安全是一种主要用于字符串操作函数相关的计算机编程术语。一个二进制安全功能(函数),其本质上将操作输入作为原始的、无任何特殊格式意义的数据流。其在操作上应包含一个字符所能有的256种可能的值(假设为8为字符)。


  那么什么是特殊格式呢?


  Special characters:Most functions are not binary safe when using any special or markup characters, such as escape codes or those that expect null-terminated strings. A possible exception would be a function whose explicit purpose is to search for a certain character in a binary string.


  大多数的函数当其使用任何特别的安全或标记字符,如转义码,还是那些期望 null 结尾的字符串,不是二进制安全的。一个可能的例外将其明确的目的是要搜索的二进制字符串中的某些字符的函数。


  数据格式化:


 Data format

Binary safe functions are required when working with data of unknown format (otherwise the format would not be preserved) such as arbitrary files, encrypted data, and the like. The length of the data must be known by the function in order to operate on the entirety of the data.


  在对未知格式的数据(尽管此格式无需保存),例如随意的文件、加密数据及类似情况时,二进制安全功能是必须的。数据长度须知以便函数操作整体数据。

猜你喜欢

转载自blog.csdn.net/it_man/article/details/42639239