Y... ¿cual es el problema? Si cambio el final por:<div><br></div><div><div> cifr = encripta("Texto a Encriptar",1 ,"Clave")</div><div> print encripta(cifr, 2, "Clave")</div></div><div><br></div>
<div>Obtengo:</div><div><br></div><div><div> Texto a Encriptar</div></div><div><br></div><div>que es lo que esperaría.</div><div class="gmail_extra"><br><br><div class="gmail_quote">2012/12/10 Lucas Alvarez <span dir="ltr"><<a href="mailto:alvarezlucas@gmail.com" target="_blank">alvarezlucas@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">La verdad que si.... el identado se fue al carajo.... lo puse en pastebin como lo sugerís.. <div class="HOEnZb"><div class="h5">
<div><br></div><div><ol style="margin:0px;padding:0px 0px 0px 48px;color:rgb(172,172,172);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace,serif;font-size:12px;line-height:21px;background-color:rgb(248,248,248)">
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"><span style="color:rgb(128,128,128);font-style:italic"># usr/bin/env python</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"><span style="color:rgb(128,128,128);font-style:italic"># -*- coding: UTF-8 -*-</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"><span style="color:rgb(128,128,128);font-style:italic"># Encripta y Desencripta un texto dependiendo de la clave de usuario</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)">debug <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(0,128,0)">False</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li><li>
<div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"><span style="color:rgb(255,119,0);font-weight:bold">def</span> encripta<span>(</span>Texto<span style="color:rgb(102,204,102)">,</span> Accion<span style="color:rgb(102,204,102)">,</span> ClaveUsuario<span>)</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> temp <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(255,69,0)">0</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> i <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(255,69,0)">0</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> j <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(255,69,0)">0</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> n <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(0,128,0)">len</span><span>(</span>ClaveUsuario<span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> rtn <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(72,61,139)">""</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(128,128,128);font-style:italic"># Convierto la cadena ClaveUsuario a una lista ascii</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> ClaveUsuarioASCII <span style="color:rgb(102,204,102)">=</span> <span>[</span><span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">for</span> i <span style="color:rgb(255,119,0);font-weight:bold">in</span> <span style="color:rgb(0,128,0)">range</span><span>(</span><span style="color:rgb(255,69,0)">0</span><span style="color:rgb(102,204,102)">,</span> n<span>)</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> ClaveUsuarioASCII.<span>append</span><span>(</span><span style="color:rgb(0,128,0)">ord</span><span>(</span>ClaveUsuario<span>[</span>i<span>]</span><span>)</span><span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"-----------------------------------------------------------"</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"La Lista ClaveUsuario: ---> "</span><span style="color:rgb(102,204,102)">,</span> ClaveUsuarioASCII</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"La Letra Seria: ---> "</span><span style="color:rgb(102,204,102)">,</span> ClaveUsuario<span>[</span>i<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(128,128,128);font-style:italic"># Convierto la cadena texto a una lista ascii</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> TextoASCII <span style="color:rgb(102,204,102)">=</span> <span>[</span><span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> d <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(0,128,0)">len</span><span>(</span>Texto<span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">for</span> i <span style="color:rgb(255,119,0);font-weight:bold">in</span> <span style="color:rgb(0,128,0)">range</span><span>(</span><span style="color:rgb(255,69,0)">0</span><span style="color:rgb(102,204,102)">,</span> d<span>)</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> TextoASCII.<span>append</span><span>(</span><span style="color:rgb(0,128,0)">ord</span><span>(</span>Texto<span>[</span>i<span>]</span><span>)</span><span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"-----------------------------------------------------------"</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"La Lista TextoAsccii: ---> "</span><span style="color:rgb(102,204,102)">,</span> TextoASCII</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"La Letra Seria: ---> "</span><span style="color:rgb(102,204,102)">,</span> Texto<span>[</span>i<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(128,128,128);font-style:italic"># Encriptar Texto</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> Accion <span style="color:rgb(102,204,102)">==</span> <span style="color:rgb(255,69,0)">1</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">for</span> i <span style="color:rgb(255,119,0);font-weight:bold">in</span> <span style="color:rgb(0,128,0)">range</span><span>(</span><span style="color:rgb(255,69,0)">0</span><span style="color:rgb(102,204,102)">,</span> d<span>)</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> j + <span style="color:rgb(255,69,0)">1</span> <span style="color:rgb(102,204,102)">>=</span> n:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> j <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(255,69,0)">1</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">else</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> j <span style="color:rgb(102,204,102)">=</span> j + <span style="color:rgb(255,69,0)">1</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"-----------------------------------------------------------"</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"Letra del Texto en ASCII --->: "</span><span style="color:rgb(102,204,102)">,</span> TextoASCII<span>[</span>i<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> <span style="color:rgb(72,61,139)">"Numero en Clave Usuario --->: "</span><span style="color:rgb(102,204,102)">,</span> ClaveUsuarioASCII<span>[</span>j<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> temp <span style="color:rgb(102,204,102)">=</span> TextoASCII<span>[</span>i<span>]</span> + ClaveUsuarioASCII<span>[</span>j<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> temp <span style="color:rgb(102,204,102)">></span> <span style="color:rgb(255,69,0)">255</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> temp <span style="color:rgb(102,204,102)">=</span> temp + <span style="color:rgb(255,69,0)">255</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> temp</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> rtn <span style="color:rgb(102,204,102)">=</span> rtn + <span style="color:rgb(0,128,0)">chr</span><span>(</span>temp<span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> rtn</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(128,128,128);font-style:italic"># Desencriptar</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">elif</span> Accion <span style="color:rgb(102,204,102)">==</span> <span style="color:rgb(255,69,0)">2</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">for</span> i <span style="color:rgb(255,119,0);font-weight:bold">in</span> <span style="color:rgb(0,128,0)">range</span><span>(</span><span style="color:rgb(255,69,0)">0</span><span style="color:rgb(102,204,102)">,</span> d<span>)</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> j + <span style="color:rgb(255,69,0)">1</span> <span style="color:rgb(102,204,102)">>=</span> n:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> j <span style="color:rgb(102,204,102)">=</span> <span style="color:rgb(255,69,0)">1</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">else</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> j <span style="color:rgb(102,204,102)">=</span> j + <span style="color:rgb(255,69,0)">1</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> TextoASCII<span>[</span>i<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> ClaveUsuarioASCII<span>[</span>j<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> temp <span style="color:rgb(102,204,102)">=</span> TextoASCII<span>[</span>i<span>]</span> - ClaveUsuarioASCII<span>[</span>j<span>]</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> temp</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> temp <span style="color:rgb(102,204,102)"><</span> <span style="color:rgb(255,69,0)">0</span>:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> temp <span style="color:rgb(102,204,102)">=</span> temp + <span style="color:rgb(255,69,0)">255</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">if</span> debug:</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">print</span> temp</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> rtn <span style="color:rgb(102,204,102)">=</span> rtn + <span style="color:rgb(0,128,0)">chr</span><span>(</span>temp<span>)</span></div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> <span style="color:rgb(255,119,0);font-weight:bold">return</span> rtn</div>
</li><li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"> </div></li>
<li><div style="padding:0px 5px;vertical-align:top;color:rgb(0,0,0);border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);background-color:rgb(255,255,255)"><span style="color:rgb(255,119,0);font-weight:bold">print</span> encripta<span>(</span><span style="color:rgb(72,61,139)">"Texto a Encriptar"</span><span style="color:rgb(102,204,102)">,</span><span style="color:rgb(255,69,0)">1</span> <span style="color:rgb(102,204,102)">,</span><span style="color:rgb(72,61,139)">"Clave"</span><span>)</span></div>
</li></ol></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2012/12/10 G V <span dir="ltr"><<a href="mailto:nadaird@gmail.com" target="_blank">nadaird@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Creo que el indentado se ha ido al carajo, o eso o tu problema es justo ese. Puedes usar herramientas como pastebin para que se pueda leer mejor el codigo a la hora de compartirlo.<div><br></div><div>Un saludo</div><div class="gmail_extra">
<br><br><div class="gmail_quote">2012/12/10 Lucas Alvarez <span dir="ltr"><<a href="mailto:alvarezlucas@gmail.com" target="_blank">alvarezlucas@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>
Hola gente, vengo dando mis primeros pasos en python y estoy intentando realizar un encriptador, el tema es que estoy tan quemado con el codigo que ya no veo donde tengo el error al momento de desencriptar.<div><br></div>
<div>
Si alguien lo ve y me puede dar una mano mas que agradecido... aqui el codigo:</div><div><br></div><div><p style="margin:0px"># usr/bin/env python</p>
<p style="margin:0px"># -*- coding: UTF-8 -*-</p>
<p style="margin:0px"># Encripta y Desencripta un texto dependiendo de la clave de usuario</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">debug = False</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">def encripta(Texto, Accion, ClaveUsuario):</p><p style="margin:0px"> temp = 0</p>
<p style="margin:0px"> i = 0</p>
<p style="margin:0px"> j = 0</p>
<p style="margin:0px"> n = len(ClaveUsuario)</p>
<p style="margin:0px"> rtn = ""</p>
<p style="margin:0px"> # Convierto la cadena ClaveUsuario a una lista ascii</p>
<p style="margin:0px"> ClaveUsuarioASCII = []</p>
<p style="margin:0px"> for i in range(0, n):</p>
<p style="margin:0px"> ClaveUsuarioASCII.append(ord(ClaveUsuario[i]))</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print "-----------------------------------------------------------"</p>
<p style="margin:0px"> print "La Lista ClaveUsuario: ---> ", ClaveUsuarioASCII</p>
<p style="margin:0px"> print "La Letra Seria: ---> ", ClaveUsuario[i]</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> # Convierto la cadena texto a una lista ascii</p>
<p style="margin:0px"> TextoASCII = []</p>
<p style="margin:0px"> d = len(Texto)</p>
<p style="margin:0px"> for i in range(0, d):</p>
<p style="margin:0px"> TextoASCII.append(ord(Texto[i]))</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print "-----------------------------------------------------------"</p>
<p style="margin:0px"> print "La Lista TextoAsccii: ---> ", TextoASCII</p>
<p style="margin:0px"> print "La Letra Seria: ---> ", Texto[i]</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> # Encriptar Texto</p>
<p style="margin:0px"> if Accion == 1:</p>
<p style="margin:0px"> for i in range(0, d):</p>
<p style="margin:0px"> if j + 1 >= n:</p>
<p style="margin:0px"> j = 1</p>
<p style="margin:0px"> else:</p>
<p style="margin:0px"> j = j + 1</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print "-----------------------------------------------------------"</p>
<p style="margin:0px"> print "Letra del Texto en ASCII --->: ", TextoASCII[i]</p>
<p style="margin:0px"> print "Numero en Clave Usuario --->: ", ClaveUsuarioASCII[j]</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> temp = TextoASCII[i] + ClaveUsuarioASCII[j]</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> if temp > 255:</p>
<p style="margin:0px"> temp = temp + 255</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print temp</p>
<p style="margin:0px"> rtn = rtn + chr(temp)</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print rtn</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> # Desencriptar</p>
<p style="margin:0px"> elif Accion == 2:</p>
<p style="margin:0px"> for i in range(0, d):</p>
<p style="margin:0px"> if j + 1 >= n:</p>
<p style="margin:0px"> j = 1</p>
<p style="margin:0px"> else:</p>
<p style="margin:0px"> j = j + 1</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print TextoASCII[i]</p>
<p style="margin:0px"> print ClaveUsuarioASCII[j]</p>
<p style="margin:0px"> temp = TextoASCII[i] - ClaveUsuarioASCII[j]</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print temp</p>
<p style="margin:0px"> if temp < 0:</p>
<p style="margin:0px"> temp = temp + 255</p>
<p style="margin:0px"> if debug:</p>
<p style="margin:0px"> print temp</p>
<p style="margin:0px"> rtn = rtn + chr(temp)</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> return rtn</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">print encripta("Texto a Encriptar",1 ,"Clave")</p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px">Saludos!</p>
<p style="margin:0px"> </p></div>
<br></div></div>_______________________________________________<br>
Python-es mailing list<br>
<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Python-es mailing list<br>
<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Python-es mailing list<br>
<a href="mailto:Python-es@python.org">Python-es@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
<br></blockquote></div><br></div>