CyberChef/docs/Utils.html
2016-11-28 11:01:54 +00:00

6701 lines
No EOL
81 KiB
HTML
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>CyberChef Namespace: Utils</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html"><img class="branding-logo" src="../build/prod/images/cyberchef-32x32.png"
alt="logo"/>CyberChef</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="FlowControl.html">FlowControl</a></li><li><a href="Utils.html">Utils</a></li><li><a href="Base.html">Base</a></li><li><a href="Base64.html">Base64</a></li><li><a href="BitwiseOp.html">BitwiseOp</a></li><li><a href="ByteRepr.html">ByteRepr</a></li><li><a href="CharEnc.html">CharEnc</a></li><li><a href="Checksum.html">Checksum</a></li><li><a href="Cipher.html">Cipher</a></li><li><a href="Code.html">Code</a></li><li><a href="Compress.html">Compress</a></li><li><a href="Convert.html">Convert</a></li><li><a href="DateTime.html">DateTime</a></li><li><a href="Endian.html">Endian</a></li><li><a href="Entropy.html">Entropy</a></li><li><a href="Extract.html">Extract</a></li><li><a href="FileType.html">FileType</a></li><li><a href="HTML.html">HTML</a></li><li><a href="HTTP.html">HTTP</a></li><li><a href="Hash.html">Hash</a></li><li><a href="Hexdump.html">Hexdump</a></li><li><a href="IP.html">IP</a></li><li><a href="JS.html">JS</a></li><li><a href="MAC.html">MAC</a></li><li><a href="Numberwang.html">Numberwang</a></li><li><a href="OS.html">OS</a></li><li><a href="PublicKey.html">PublicKey</a></li><li><a href="Punycode.html">Punycode</a></li><li><a href="QuotedPrintable.html">QuotedPrintable</a></li><li><a href="Rotate.html">Rotate</a></li><li><a href="SeqUtils.html">SeqUtils</a></li><li><a href="StrUtils.html">StrUtils</a></li><li><a href="Tidy.html">Tidy</a></li><li><a href="URL_.html">URL_</a></li><li><a href="UUID.html">UUID</a></li><li><a href="Unicode.html">Unicode</a></li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="Chef.html">Chef</a></li><li><a href="Dish.html">Dish</a></li><li><a href="Ingredient.html">Ingredient</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Recipe.html">Recipe</a></li><li><a href="ControlsWaiter.html">ControlsWaiter</a></li><li><a href="HTMLApp.html">HTMLApp</a></li><li><a href="HTMLCategory.html">HTMLCategory</a></li><li><a href="HTMLIngredient.html">HTMLIngredient</a></li><li><a href="HTMLOperation.html">HTMLOperation</a></li><li><a href="HighlighterWaiter.html">HighlighterWaiter</a></li><li><a href="InputWaiter.html">InputWaiter</a></li><li><a href="Manager.html">Manager</a></li><li><a href="OperationsWaiter.html">OperationsWaiter</a></li><li><a href="OptionsWaiter.html">OptionsWaiter</a></li><li><a href="OutputWaiter.html">OutputWaiter</a></li><li><a href="RecipeWaiter.html">RecipeWaiter</a></li><li><a href="SeasonalWaiter.html">SeasonalWaiter</a></li><li><a href="WindowWaiter.html">WindowWaiter</a></li>
</ul>
</li>
<li class="dropdown">
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="Manager.html#event:appstart">Manager#event:appstart</a></li><li><a href="Manager.html#event:operationadd">Manager#event:operationadd</a></li><li><a href="Manager.html#event:operationremove">Manager#event:operationremove</a></li><li><a href="Manager.html#event:oplistcreate">Manager#event:oplistcreate</a></li><li><a href="Manager.html#event:statechange">Manager#event:statechange</a></li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="global.html#Categories">Categories</a></li><li><a href="global.html#OperationConfig">OperationConfig</a></li><li><a href="global.html#main">main</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<h1 class="page-title">Namespace: Utils</h1>
<section>
<header>
<h2>
Utils
</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Utility functions for use in operations, the core framework and the stage.</p></div>
<dl class="details">
<dt class="tag-author method-doc-label method-doc-details-label">Author:</dt>
<dd class="tag-author">
<ul>
<li>&lt;p>n1474335 [n1474335@gmail.com]&lt;/p></li>
</ul>
</dd>
<dt class="tag-copyright method-doc-label method-doc-details-label">Copyright:</dt>
<dd class="tag-copyright">
<ul class="dummy">
<li>Crown Copyright 2016</li>
</ul>
</dd>
<dt class="tag-license method-doc-label method-doc-details-label">License:</dt>
<dd class="tag-license">
<ul class="dummy">
<li>Apache-2.0</li>
</ul>
</dd>
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-12">line 12</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<dl>
<hr>
<dt class="name" id=".UNIC_WIN1251_MAP">
<h4 id=".UNIC_WIN1251_MAP"><span class="type-signature">&lt;private, static, constant> </span>UNIC_WIN1251_MAP<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Mapping of Unicode code points to Windows-1251</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-468">line 468</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id=".WIN1251_UNIC_MAP">
<h4 id=".WIN1251_UNIC_MAP"><span class="type-signature">&lt;private, static, constant> </span>WIN1251_UNIC_MAP<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Mapping of Windows-1251 code points to Unicode</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-504">line 504</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id=".char_rep">
<h4 id=".char_rep"><span class="type-signature">&lt;static, constant> </span>char_rep<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A mapping of names of delimiter characters to their symbols.</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-933">line 933</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id=".regex_rep">
<h4 id=".regex_rep"><span class="type-signature">&lt;static, constant> </span>regex_rep<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A mapping of names of delimiter characters to regular expressions which can select them.</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-951">line 951</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id=".format">
<h4 id=".format"><span class="type-signature">&lt;static, constant> </span>format<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A mapping of string formats to their classes in the CryptoJS library.</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-967">line 967</a>
</li>
</ul>
</dd>
</dl>
</dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".chr"><span class="type-signature">&lt;static> </span>chr(o)</h4>
</dt>
<dd>
<div class="description">
<p>Translates an ordinal into a character.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>o</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-24">line 24</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">char</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &#x27;a&#x27;
Utils.chr(97);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".ord"><span class="type-signature">&lt;static> </span>ord(c)</h4>
</dt>
<dd>
<div class="description">
<p>Translates a character into an ordinal.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>c</code></td>
<td class="type">
<span class="param-type">char</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-39">line 39</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns 97
Utils.ord(&#x27;a&#x27;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".pad_left"><span class="type-signature">&lt;static> </span>pad_left(str, max [, chr])</h4>
</dt>
<dd>
<div class="description">
<p>Adds leading zeros to strings</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>String to add leading characters to.</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Maximum width of the string.</p></td>
</tr>
<tr>
<td class="name"><code>chr</code></td>
<td class="type">
<span class="param-type">char</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'0'
</td>
<td class="description last"><p>The character to pad with.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-65">line 65</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;0a&quot;
Utils.pad_left(&quot;a&quot;, 2);
// returns &quot;000a&quot;
Utils.pad_left(&quot;a&quot;, 4);
// returns &quot;xxxa&quot;
Utils.pad_left(&quot;a&quot;, 4, &quot;x&quot;);
// returns &quot;bcabchello&quot;
Utils.pad_left(&quot;hello&quot;, 10, &quot;abc&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".pad_right"><span class="type-signature">&lt;static> </span>pad_right(str, max [, chr])</h4>
</dt>
<dd>
<div class="description">
<p>Adds trailing spaces to strings.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>String to add trailing characters to.</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Maximum width of the string.</p></td>
</tr>
<tr>
<td class="name"><code>chr</code></td>
<td class="type">
<span class="param-type">char</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'0'
</td>
<td class="description last"><p>The character to pad with.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-89">line 89</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;a &quot;
Utils.pad_right(&quot;a&quot;, 4);
// returns &quot;axxx&quot;
Utils.pad_right(&quot;a&quot;, 4, &quot;x&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".pad_left"><span class="type-signature">&lt;static> </span>pad_left()</h4>
</dt>
<dd>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-99">line 99</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".truncate"><span class="type-signature">&lt;static> </span>truncate(str, max [, suffix])</h4>
</dt>
<dd>
<div class="description">
<p>Truncates a long string to max length and adds suffix.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>String to truncate</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Maximum length of the final string</p></td>
</tr>
<tr>
<td class="name"><code>suffix</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'...'
</td>
<td class="description last"><p>The string to add to the end of the final string</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-119">line 119</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;A long...&quot;
Utils.truncate(&quot;A long string&quot;, 9);
// returns &quot;A long s-&quot;
Utils.truncate(&quot;A long string&quot;, 9, &quot;-&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".hex"><span class="type-signature">&lt;static> </span>hex(c [, length])</h4>
</dt>
<dd>
<div class="description">
<p>Converts a character or number to its hex representation.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>c</code></td>
<td class="type">
<span class="param-type">char</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>length</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
2
</td>
<td class="description last"><p>The width of the resulting hex number.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-142">line 142</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;6e&quot;
Utils.hex(&quot;n&quot;);
// returns &quot;6e&quot;
Utils.hex(110);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".bin"><span class="type-signature">&lt;static> </span>bin(c [, length])</h4>
</dt>
<dd>
<div class="description">
<p>Converts a character or number to its binary representation.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>c</code></td>
<td class="type">
<span class="param-type">char</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>length</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
8
</td>
<td class="description last"><p>The width of the resulting binary number.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-163">line 163</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;01101110&quot;
Utils.bin(&quot;n&quot;);
// returns &quot;01101110&quot;
Utils.bin(110);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".printable"><span class="type-signature">&lt;static> </span>printable(str [, preserve_ws])</h4>
</dt>
<dd>
<div class="description">
<p>Returns a string with all non-printable chars as dots, optionally preserving whitespace.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The input string to display.</p></td>
</tr>
<tr>
<td class="name"><code>preserve_ws</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last"><p>Whether or not to print whitespace.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-177">line 177</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".parse_escaped_chars"><span class="type-signature">&lt;static> </span>parse_escaped_chars(str)</h4>
</dt>
<dd>
<div class="description">
<p>Parse a string entered by a user and replace escaped chars with the bytes they represent.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-204">line 204</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;\x00&quot;
Utils.parse_escaped_chars(&quot;\\x00&quot;);
// returns &quot;\n&quot;
Utils.parse_escaped_chars(&quot;\\n&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".expand_alph_range"><span class="type-signature">&lt;static> </span>expand_alph_range(alph_str)</h4>
</dt>
<dd>
<div class="description">
<p>Expand an alphabet range string into a list of the characters in that range.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>alph_str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-241">line 241</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Array.html">Array</a>.&lt;char></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [&quot;0&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;]
Utils.expand_alph_range(&quot;0-9&quot;);
// returns [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;0&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;+&quot;, &quot;/&quot;]
Utils.expand_alph_range(&quot;a-d0-3+/&quot;);
// returns [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;0&quot;, &quot;-&quot;, &quot;3&quot;]
Utils.expand_alph_range(&quot;a-d0\\-3&quot;)</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".hex_to_byte_array"><span class="type-signature">&lt;static> </span>hex_to_byte_array(hex_str)</h4>
</dt>
<dd>
<div class="description">
<p>Translates a hex string into an array of bytes.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>hex_str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-278">line 278</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [0xfe, 0x09, 0xa7]
Utils.hex_to_byte_array(&quot;fe09a7&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".byte_array_to_hex"><span class="type-signature">&lt;static> </span>byte_array_to_hex(byte_array)</h4>
</dt>
<dd>
<div class="description">
<p>Translates an array of bytes to a hex string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>byte_array</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-300">line 300</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;fe09a7&quot;
Utils.byte_array_to_hex([0xfe, 0x09, 0xa7]);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".str_to_byte_array"><span class="type-signature">&lt;static> </span>str_to_byte_array(str)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a string to a byte array.<br>Treats the string as UTF-8 if any values are over 255.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-324">line 324</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [72,101,108,108,111]
Utils.str_to_byte_array(&quot;Hello&quot;);
// returns [228,189,160,229,165,189]
Utils.str_to_byte_array(&quot;你好&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".str_to_utf8_byte_array"><span class="type-signature">&lt;static> </span>str_to_utf8_byte_array(str)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a string to a UTF-8 byte array.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-350">line 350</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [72,101,108,108,111]
Utils.str_to_utf8_byte_array(&quot;Hello&quot;);
// returns [228,189,160,229,165,189]
Utils.str_to_utf8_byte_array(&quot;你好&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".str_to_charcode"><span class="type-signature">&lt;static> </span>str_to_charcode(str)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a string to a charcode array</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-373">line 373</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [72,101,108,108,111]
Utils.str_to_charcode(&quot;Hello&quot;);
// returns [20320,22909]
Utils.str_to_charcode(&quot;你好&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".byte_array_to_utf8"><span class="type-signature">&lt;static> </span>byte_array_to_utf8(byte_array)</h4>
</dt>
<dd>
<div class="description">
<p>Attempts to convert a byte array to a UTF-8 string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>byte_array</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-396">line 396</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;Hello&quot;
Utils.byte_array_to_utf8([72,101,108,108,111]);
// returns &quot;你好&quot;
Utils.byte_array_to_utf8([228,189,160,229,165,189]);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".byte_array_to_chars"><span class="type-signature">&lt;static> </span>byte_array_to_chars(byte_array)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a charcode array to a string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>byte_array</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-429">line 429</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;Hello&quot;
Utils.byte_array_to_chars([72,101,108,108,111]);
// returns &quot;你好&quot;
Utils.byte_array_to_chars([20320,22909]);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".word_array_to_byte_array"><span class="type-signature">&lt;static> </span>word_array_to_byte_array(word_array)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a CryptoJS.lib.WordArray to a byte_array.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>word_array</code></td>
<td class="type">
<span class="param-type">CryptoJS.lib.WordArray</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-449">line 449</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [84, 101, 115, 116]
Utils.word_array_to_byte_array(CryptoJS.enc.Hex.parse(&quot;54657374&quot;));</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".unicode_to_win1251"><span class="type-signature">&lt;static> </span>unicode_to_win1251(unic_str)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a Unicode string to Windows-1251 encoding</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>unic_str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-546">line 546</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>String encoded in Windows-1251</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;îáíîâëåííàÿ òåõíè÷êà ïî Áîèíãó. îðèãèíàë ó ìåíÿ. çàáåðåòå êîãäà áóäåòå â ÊÈ&quot;
Utils.unicode_to_win1251(&quot;обновленная техничка по Боингу. оригинал у меня. заберете когда будете в КИ&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".win1251_to_unicode"><span class="type-signature">&lt;static> </span>win1251_to_unicode(win1251_str)</h4>
</dt>
<dd>
<div class="description">
<p>Converts a Windows-1251 string to Unicode encoding</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>win1251_str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-570">line 570</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>String encoded in Unicode</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;обновленная техничка по Боингу. оригинал у меня. заберете когда будете в КИ&quot;
Utils.unicode_to_win1251(&quot;îáíîâëåííàÿ òåõíè÷êà ïî Áîèíãó. îðèãèíàë ó ìåíÿ. çàáåðåòå êîãäà áóäåòå â ÊÈ&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".to_base64"><span class="type-signature">&lt;static> </span>to_base64(data [, alphabet])</h4>
</dt>
<dd>
<div class="description">
<p>Base64's the input byte array using the given alphabet, returning a string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">byte_array</span>
|
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>alphabet</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-598">line 598</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;SGVsbG8=&quot;
Utils.to_base64([72, 101, 108, 108, 111]);
// returns &quot;SGVsbG8=&quot;
Utils.to_base64(&quot;Hello&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".from_base64"><span class="type-signature">&lt;static> </span>from_base64(data [, alphabet] [, return_type] [, remove_non_alph_chars])</h4>
</dt>
<dd>
<div class="description">
<p>UnBase64's the input string using the given alphabet, returning a byte array.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>alphabet</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>return_type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
"string"
</td>
<td class="description last"><p>Either &quot;string&quot; or &quot;byte_array&quot;</p></td>
</tr>
<tr>
<td class="name"><code>remove_non_alph_chars</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-652">line 652</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;Hello&quot;
Utils.from_base64(&quot;SGVsbG8=&quot;);
// returns [72, 101, 108, 108, 111]
Utils.from_base64(&quot;SGVsbG8=&quot;, null, &quot;byte_array&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".to_hex"><span class="type-signature">&lt;static> </span>to_hex(data [, delim] [, padding])</h4>
</dt>
<dd>
<div class="description">
<p>Convert a byte array into a hex string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>delim</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
" "
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>padding</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
2
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-718">line 718</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;0a 14 1e&quot;
Utils.to_hex([10,20,30]);
// returns &quot;0a:14:1e&quot;
Utils.to_hex([10,20,30], &quot;:&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".to_hex_fast"><span class="type-signature">&lt;static> </span>to_hex_fast(data)</h4>
</dt>
<dd>
<div class="description">
<p>Convert a byte array into a hex string as efficiently as possible with no options.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">byte_array</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-750">line 750</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;0a141e&quot;
Utils.to_hex([10,20,30]);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".from_hex"><span class="type-signature">&lt;static> </span>from_hex(data [, delim] [, byte_len])</h4>
</dt>
<dd>
<div class="description">
<p>Convert a hex string into a byte array.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>delim</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>byte_len</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
2
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-779">line 779</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">byte_array</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [10,20,30]
Utils.from_hex(&quot;0a 14 1e&quot;);
// returns [10,20,30]
Utils.from_hex(&quot;0a:14:1e&quot;, &quot;Colon&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".parse_csv"><span class="type-signature">&lt;static> </span>parse_csv(data)</h4>
</dt>
<dd>
<div class="description">
<p>Parses CSV data and returns it as a two dimensional array or strings.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-805">line 805</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Array.html">Array</a>.&lt;<a href="Array.html">Array</a>.&lt;string>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns [[&quot;head1&quot;, &quot;head2&quot;], [&quot;data1&quot;, &quot;data2&quot;]]
Utils.parse_csv(&quot;head1,head2\ndata1,data2&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".strip_html_tags"><span class="type-signature">&lt;static> </span>strip_html_tags(html_str, remove_script_and_style)</h4>
</dt>
<dd>
<div class="description">
<p>Removes all HTML (or XML) tags from the input string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>html_str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>remove_script_and_style</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last"><p>Flag to specify whether to remove entire script or style blocks</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-859">line 859</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;Test&quot;
Utils.strip_html_tags(&quot;&lt;div&gt;Test&lt;/div&gt;&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".escape_html"><span class="type-signature">&lt;static> </span>escape_html(str)</h4>
</dt>
<dd>
<div class="description">
<p>Escapes HTML tags in a string to stop them being rendered</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-877">line 877</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>string</p>
</div>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// return &quot;A &amp;lt;script&gt; tag&quot;
Utils.escape_html(&quot;A &lt;script&gt; tag&quot;);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".fuzzy_time"><span class="type-signature">&lt;static> </span>fuzzy_time(ms)</h4>
</dt>
<dd>
<div class="description">
<p>Expresses a number of milliseconds in a human readable format.</p>
<table>
<thead>
<tr>
<th>Range</th>
<th>Sample Output</th>
</tr>
</thead>
<tbody>
<tr>
<td>0 to 45 seconds</td>
<td>a few seconds ago</td>
</tr>
<tr>
<td>45 to 90 seconds</td>
<td>a minute ago</td>
</tr>
<tr>
<td>90 seconds to 45 minutes</td>
<td>2 minutes ago ... 45 minutes ago</td>
</tr>
<tr>
<td>45 to 90 minutes</td>
<td>an hour ago</td>
</tr>
<tr>
<td>90 minutes to 22 hours</td>
<td>2 hours ago ... 22 hours ago</td>
</tr>
<tr>
<td>22 to 36 hours</td>
<td>a day ago</td>
</tr>
<tr>
<td>36 hours to 25 days</td>
<td>2 days ago ... 25 days ago</td>
</tr>
<tr>
<td>25 to 45 days</td>
<td>a month ago</td>
</tr>
<tr>
<td>45 to 345 days</td>
<td>2 months ago ... 11 months ago</td>
</tr>
<tr>
<td>345 to 545 days (1.5 years)</td>
<td>a year ago</td>
</tr>
<tr>
<td>546 days+</td>
<td>2 years ago ... 20 years ago</td>
</tr>
</tbody>
</table>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ms</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-909">line 909</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">// returns &quot;3 minutes&quot;
Utils.fuzzy_time(152435);
// returns &quot;5 days&quot;
Utils.fuzzy_time(456851321);</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".extend"><span class="type-signature">&lt;static> </span>extend(a, b)</h4>
</dt>
<dd>
<div class="description">
<p>Adds the properties of one Object to another.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="core_Utils.js.html">core/Utils.js</a>,
<a href="core_Utils.js.html#sunlight-1-line-921">line 921</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
&copy; Crown Copyright 2016
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
on Mon Nov 28th 2016
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>