fluentnode
Version:
Fluent apis for node (based on the concepts used in C#'s FluentSharp
440 lines (278 loc) • 14.5 kB
HTML
<html>
<head>
<title>crypto.litcoffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="assert_Array.html">
assert_Array.litcoffee
</a>
<a class="source" href="assert_Boolean.html">
assert_Boolean.litcoffee
</a>
<a class="source" href="assert_Function.html">
assert_Function.litcoffee
</a>
<a class="source" href="assert_Number.html">
assert_Number.litcoffee
</a>
<a class="source" href="assert_Object.html">
assert_Object.litcoffee
</a>
<a class="source" href="assert_String.html">
assert_String.litcoffee
</a>
<a class="source" href="fluentnode.html">
fluentnode.coffee
</a>
<a class="source" href="index.html">
index.md
</a>
<a class="source" href="Array.html">
Array.litcoffee
</a>
<a class="source" href="Boolean.html">
Boolean.litcoffee
</a>
<a class="source" href="Function.html">
Function.litcoffee
</a>
<a class="source" href="Number.html">
Number.litcoffee
</a>
<a class="source" href="Object.html">
Object.litcoffee
</a>
<a class="source" href="String.html">
String.litcoffee
</a>
<a class="source" href="console.html">
console.litcoffee
</a>
<a class="source" href="crypto.html">
crypto.litcoffee
</a>
<a class="source" href="fs.html">
fs.litcoffee
</a>
<a class="source" href="http.GET.html">
http.GET.litcoffee
</a>
<a class="source" href="http.POST.html">
http.POST.litcoffee
</a>
<a class="source" href="http.Server.html">
http.Server.litcoffee
</a>
<a class="source" href="http.html">
http.litcoffee
</a>
<a class="source" href="path.html">
path.litcoffee
</a>
<a class="source" href="process.html">
process.litcoffee
</a>
<a class="source" href="encoding.html">
encoding.litcoffee
</a>
<a class="source" href="globals.html">
globals.litcoffee
</a>
<a class="source" href="assert_Array.test.html">
assert_Array.test.coffee
</a>
<a class="source" href="assert_Boolean.test.html">
assert_Boolean.test.coffee
</a>
<a class="source" href="assert_Function.test.html">
assert_Function.test.coffee
</a>
<a class="source" href="assert_Number.test.html">
assert_Number.test.coffee
</a>
<a class="source" href="assert_Object.test.html">
assert_Object.test.coffee
</a>
<a class="source" href="assert_String.test.html">
assert_String.test.coffee
</a>
<a class="source" href="fluentnode.test.html">
fluentnode.test.coffee
</a>
<a class="source" href="Array.test.html">
Array.test.coffee
</a>
<a class="source" href="Boolean.test.html">
Boolean.test.coffee
</a>
<a class="source" href="Function.test.html">
Function.test.coffee
</a>
<a class="source" href="Number.test.html">
Number.test.coffee
</a>
<a class="source" href="Object.test.html">
Object.test.coffee
</a>
<a class="source" href="String.test.html">
String.test.coffee
</a>
<a class="source" href="console.test.html">
console.test.coffee
</a>
<a class="source" href="crypto.test.html">
crypto.test.coffee
</a>
<a class="source" href="fs.test.html">
fs.test.coffee
</a>
<a class="source" href="http.GET.test.html">
http.GET.test.coffee
</a>
<a class="source" href="http.POST.test.html">
http.POST.test.coffee
</a>
<a class="source" href="http.Server.test.html">
http.Server.test.coffee
</a>
<a class="source" href="http.test.html">
http.test.coffee
</a>
<a class="source" href="path.test.html">
path.test.coffee
</a>
<a class="source" href="process.test.html">
process.test.coffee
</a>
<a class="source" href="encoding.test.html">
encoding.test.coffee
</a>
<a class="source" href="globals.test.html">
globals.test.coffee
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>crypto.litcoffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
<p>Methods that use the node crypto API</p>
<p>dependencies</p>
</div>
<div class="content"><div class='highlight'><pre>crypto = <span class="hljs-built_in">require</span>(<span class="hljs-string">'crypto'</span>)</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<p>@.<strong>add_Random_Chars</strong> size</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_Random_Chars = <span class="hljs-function"><span class="hljs-params">(size )</span>-></span>
@ + crypto.randomBytes(size || <span class="hljs-number">10</span>)</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p>@.<strong>add_Random_String</strong> size</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_Random_String = <span class="hljs-function"><span class="hljs-params">(size )</span>-></span>
@ + crypto.randomBytes(size || <span class="hljs-number">10</span>).toString(<span class="hljs-string">'hex'</span>).slice(<span class="hljs-number">0</span>,size|| <span class="hljs-number">10</span>)</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p>@.<strong>add_Random_Letters</strong> size</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_Random_Letters = <span class="hljs-function"><span class="hljs-params">(size )</span>-></span>
charSet = <span class="hljs-string">'abcdefghijklmnopqrstuvwxyz'</span>
@ + (charSet[Math.floor(Math.random() * charSet.length)] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span>.size]).join(<span class="hljs-string">''</span>)</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>@.<strong>add_5_Random_Letters</strong></p>
<p>Adds 5 random letters to <code>@</code></p>
<p>twin methods: add_5_Letters</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_5_Random_Letters = <span class="hljs-function"><span class="hljs-params">()</span>-></span>
@.add_Random_Letters(<span class="hljs-number">5</span>)
<span class="hljs-attribute">String</span>::add_5_Letters = <span class="hljs-attribute">String</span>::add_5_Random_Letters</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">¶</a>
</div>
<p>@.<strong>add_Random_Numbers</strong> size</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_Random_Numbers = <span class="hljs-function"><span class="hljs-params">(size)</span>-></span>
charSet = <span class="hljs-string">'0123456789'</span>
@ + (charSet[Math.floor(Math.random() * charSet.length)] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span>.size]).join(<span class="hljs-string">''</span>)</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">¶</a>
</div>
<p>@.<strong>checksum</strong> [algorithm], [encoding]</p>
<p>Returns a checksum for @ </p>
<p>Defaults to <code>md5</code> algorithm and <code>hex</code> encoding</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::checksum = <span class="hljs-function"><span class="hljs-params">(algorithm, encoding)</span>-></span>
crypto.createHash(algorithm || <span class="hljs-string">'md5'</span>)
.update(@.toString(), <span class="hljs-string">'utf8'</span>)
.digest(encoding || <span class="hljs-string">'hex'</span>)</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">¶</a>
</div>
<p>@.<strong>random_String</strong> ()</p>
<p>Returns a random string of size @ made of ascii chars</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">Number</span>::random_String = <span class="hljs-function">-></span>
<span class="hljs-string">""</span>.add_Random_String(@ + <span class="hljs-number">0</span>)</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">¶</a>
</div>
<p>@.<strong>random_Letters</strong> ()</p>
<p>Returns a random string of size @ made of only letters</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">Number</span>::random_Letters = <span class="hljs-function">-></span>
<span class="hljs-string">""</span>.add_Random_Letters(@ + <span class="hljs-number">0</span>)</pre></div></div>
</li>
</ul>
</div>
</body>
</html>