MobileBlur

Artifact [d89a1ae043]
Login

Artifact [d89a1ae043]

Artifact d89a1ae04377f94fa965bc7d87d8feb7955e7433:


<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>web2py.gluon.utils</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="web2py.gluon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.web2py.com">web2py Web Framework</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;web2py ::
        <a href="web2py.gluon-module.html">Package&nbsp;gluon</a> ::
        Module&nbsp;utils
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="web2py.gluon.utils-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module utils</h1><span class="codelink"><a href="web2py.gluon.utils-pysrc.html">source&nbsp;code</a></span><br /><br />
<p>This file is part of the web2py Web Framework Copyrighted by Massimo 
  Di Pierro &lt;mdipierro@cs.depaul.edu&gt; License: LGPLv3 
  (http://www.gnu.org/licenses/lgpl.html)</p>
  This file specifically includes utilities for security.<br /><br />

<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="md5_hash"></a><span class="summary-sig-name">md5_hash</span>(<span class="summary-sig-arg">text</span>)</span><br />
      Generate a md5 hash with the given text</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#md5_hash">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="simple_hash"></a><span class="summary-sig-name">simple_hash</span>(<span class="summary-sig-arg">text</span>,
        <span class="summary-sig-arg">digest_alg</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">md5</code><code class="variable-quote">'</code></span>)</span><br />
      Generates hash with the given text using the specified digest 
      hashing algorithm</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#simple_hash">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="get_digest"></a><span class="summary-sig-name">get_digest</span>(<span class="summary-sig-arg">value</span>)</span><br />
      Returns a hashlib digest algorithm from a string</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#get_digest">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="hmac_hash"></a><span class="summary-sig-name">hmac_hash</span>(<span class="summary-sig-arg">value</span>,
        <span class="summary-sig-arg">key</span>,
        <span class="summary-sig-arg">digest_alg</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">md5</code><code class="variable-quote">'</code></span>,
        <span class="summary-sig-arg">salt</span>=<span class="summary-sig-default">1</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#hmac_hash">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="web2py.gluon.utils-module.html#initialize_urandom" class="summary-sig-name">initialize_urandom</a>()</span><br />
      This function and the web2py_uuid follow from the following 
      discussion: 
      http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#initialize_urandom">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="web2py.gluon.utils-module.html#web2py_uuid" class="summary-sig-name">web2py_uuid</a>()</span><br />
      This function follows from the following discussion: 
      http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="web2py.gluon.utils-pysrc.html#web2py_uuid">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="logger"></a><span class="summary-name">logger</span> = <code title="logging.getLogger(&quot;web2py&quot;)">logging.getLogger(&quot;web2py&quot;)</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="web2py.gluon.utils-module.html#ctokens" class="summary-name">ctokens</a> = <code title="[176,
 173,
 75,
 184,
 184,
 169,
 176,
 173,
..."><code class="variable-group">[</code>176<code class="variable-op">, </code>173<code class="variable-op">, </code>75<code class="variable-op">, </code>184<code class="variable-op">, </code>184<code class="variable-op">, </code>169<code class="variable-op">, </code>176<code class="variable-op">, </code>173<code class="variable-op">, </code>75<code class="variable-op">, </code>184<code class="variable-op">, </code>184<code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="initialize_urandom"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">initialize_urandom</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="web2py.gluon.utils-pysrc.html#initialize_urandom">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>This function and the web2py_uuid follow from the following 
  discussion: 
  http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09</p>
  <p>At startup web2py compute a unique ID that identifies the machine by 
  adding uuid.getnode() + int(time.time() * 1e3)</p>
  <p>This is a 48-bit number. It converts the number into 16 8-bit tokens. 
  It uses this value to initialize the entropy source ('/dev/urandom') and 
  to seed random.</p>
  If os.random() is not supported, it falls back to using random and 
  issues a warning.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="web2py_uuid"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">web2py_uuid</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="web2py.gluon.utils-pysrc.html#web2py_uuid">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>This function follows from the following discussion: 
  http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09</p>
  It works like uuid.uuid4 except that tries to use os.urandom() if 
  possible and it XORs the output with the tokens uniquely associated with 
  this machine.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-VariablesDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="ctokens"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">ctokens</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">[</code>176<code class="variable-op">,</code>
 173<code class="variable-op">,</code>
 75<code class="variable-op">,</code>
 184<code class="variable-op">,</code>
 184<code class="variable-op">,</code>
 169<code class="variable-op">,</code>
 176<code class="variable-op">,</code>
 173<code class="variable-op">,</code>
<code class="variable-ellipsis">...</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="web2py.gluon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.web2py.com">web2py Web Framework</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Thu Aug  4 00:46:59 2011
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>