Secure Hash
9
Fixed the regular expression to check for more strict requirements.
14
This function calculates how many lines will text occupy.
Example (simple):
$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus tincidunt posuere dolor";
$num_lines = how_many_lines(10, $string);
It accepts a third, optional, parameter $options, that allows you to change behaviour. $options should be array. Following configuration options are available:
'white_spaces' - default: array(' ', "\t") - array of chars, that should be treated as whitespace.
'new_lines' - default: array("\r\n", "\n") - array of strings, that should be treated as newlines. For example, for HTML you can set 'new_lines' => array('');
'force_line_breaks' - default: true - force wrapping, when the token is longer than width, or not. If set to false, and token cannot be fitted into $width, function will return false;
'callback' - default: null - callback function for determining character width. Must accept at least one parameter - $char
'callback_params' - default: array() - optional additional callback parameters
'char_widths' - default: null - associative array in a form $char => $width, which contains char width. If $char is not found in the array, it's width is defaulted to 0.
Example (simple):
$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus tincidunt posuere dolor";
$num_lines = how_many_lines(10, $string);
It accepts a third, optional, parameter $options, that allows you to change behaviour. $options should be array. Following configuration options are available:
'white_spaces' - default: array(' ', "\t") - array of chars, that should be treated as whitespace.
'new_lines' - default: array("\r\n", "\n") - array of strings, that should be treated as newlines. For example, for HTML you can set 'new_lines' => array('');
'force_line_breaks' - default: true - force wrapping, when the token is longer than width, or not. If set to false, and token cannot be fitted into $width, function will return false;
'callback' - default: null - callback function for determining character width. Must accept at least one parameter - $char
'callback_params' - default: array() - optional additional callback parameters
'char_widths' - default: null - associative array in a form $char => $width, which contains char width. If $char is not found in the array, it's width is defaulted to 0.
10
Format Bytes
7
Remove newslines from a string.
-7
Databinding in asp.net 2.0 takes very few lines of code. This example shows how to bind a CheckBoxList using a SqlDataSource.
-8
Databinding in asp.net 2.0 is takes very few lines of code.
12
If you have ever written a website or java application where people paste stuff in from Word, you are likely to have hit the problem of Word using high ascii chars for "open quotes", "close quotes", reg symbol, etc...
This java class (with a single static method) can replace the most prevalent of these with normal ascii values
Hope it helps someone...
This java class (with a single static method) can replace the most prevalent of these with normal ascii values
Hope it helps someone...
8
Convert a password returned by JPasswordField::getPassword() into a String.
11
From RSA Security's website:
"RC4 is a stream cipher designed by Rivest for RSA Data Security (now RSA Security). It is a variable key-size stream cipher with byte-oriented operations. The algorithm is based on the use of a random permutation. Analysis shows that the period of the cipher is overwhelmingly likely to be greater than 10^100. Eight to sixteen machine operations are required per output byte, and the cipher can be expected to run very quickly in software. Independent analysts have scrutinized the algorithm and it is considered secure."
This implementation encodes the byte stream to be encrypted "in-place".
Example:
"RC4 is a stream cipher designed by Rivest for RSA Data Security (now RSA Security). It is a variable key-size stream cipher with byte-oriented operations. The algorithm is based on the use of a random permutation. Analysis shows that the period of the cipher is overwhelmingly likely to be greater than 10^100. Eight to sixteen machine operations are required per output byte, and the cipher can be expected to run very quickly in software. Independent analysts have scrutinized the algorithm and it is considered secure."
This implementation encodes the byte stream to be encrypted "in-place".
Example:
Byte[] Key = new Byte[5] { 12, 34, 22, 12, 32 };
Byte[] B = new Byte[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// Examine B array before and after this next call.
RC4(ref B, Key);
// Examine B array before and after this next call.
RC4(ref B, Key);
7
mattrmiller
Formats milliseconds into a duration string.









