https://github.com/dflydev/dflydev-snort-textorbinary
[READ-ONLY] Subtree split of Dflydev\Snort\TextOrBinary.
https://github.com/dflydev/dflydev-snort-textorbinary
Last synced: about 1 month ago
JSON representation
[READ-ONLY] Subtree split of Dflydev\Snort\TextOrBinary.
- Host: GitHub
- URL: https://github.com/dflydev/dflydev-snort-textorbinary
- Owner: dflydev
- License: mit
- Created: 2013-01-13T06:48:42.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-13T17:20:09.000Z (over 13 years ago)
- Last Synced: 2025-03-21T10:51:16.218Z (about 1 year ago)
- Language: PHP
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Snort - Text or Binary
======================
Buffer analysis to determine whether a Buffer is more likely to represent text
or binary data.
Requirements
------------
* PHP 5.3+
Installation
------------
Through [Composer][1] as [dflydev/snort-textorbinary][2].
Usage
-----
```php
addData($bytes, 0, strlen($bytes));
$sniffer = new Dflydev\Snort\TextOrBinary\TextOrBinarySniffer;
if ($sniffer->isLikelyText($buffer)) {
print "Well, probably text? (as best as we can guess in 512 bytes...)\n";
}
if ($sniffer->isLikelyBinary($buffer)) {
print "Well, probably binary? (as best as we can guess in 512 bytes...)\n";
}
if ($sniffer->isMostlyAscii($buffer)) {
print "Yup, Mostly ASCII!\n";
}
if ($sniffer->looksLikeUtf8($buffer)) {
print "Yup, UTF-8!\n";
}
```
License
-------
MIT, see LICENSE.
Community
---------
If you have questions or want to help out, join us in the **#dflydev** channel
on **irc.freenode.net** or mention [@dflydev][4] on Twitter.
Not Invented Here
-----------------
This work was heavily influenced by [Apache Tika][3].
[1]: http://getcomposer.org
[2]: https://packagist.org/packages/dflydev/snort-textorbinary
[3]: http://tika.apache.org
[4]: https://twitter.com/dflydev