<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 17, 2014 at 7:25 PM, Ron Teitelbaum <span dir="ltr">&lt;<a href="mailto:ron@usmedrec.com" target="_blank" class="vt-p">ron@usmedrec.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal">
<span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Mariano,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Before I give you an answer, you should never ever ever not even for any reason, ever, did I mention ever, store a user&rsquo;s password.&nbsp; You can hash a password, which means you store the hash value of the password.&nbsp; You can make it more secure by salting the hash or embedding your own key to the hash, or doing a number of other things. &nbsp;But you should always store an encrypted hash and never a recoverable password.&nbsp; The way this works is that your user knows the password and can generate a hash at any time that you can compare.&nbsp; You store the hash of the password to compare.&nbsp; The reason for this should be obvious.&nbsp; You don&rsquo;t want anyone to have access to that password.&nbsp; Not even programmers.&nbsp; Your program doesn&rsquo;t need it either since the user can generate that hash for you at any time.&nbsp; It really is all you ever need to store.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;</span></p></div></div></blockquote><div><br></div><div>Hi Ron,</div><div><br></div><div>Thanks for the advice. I have been warned about this in the past so I am NOT using this for storing passwords. Instead, there are instVars from certain objects that are &quot;password protected&quot; because they represent some sensible data. So these fields need to be encrypted/decrypted. The user needs to supply a password for editing/viewing them. These fields were encrypted/decrypted with Blowfish. And the key for the blowfish is the &quot;&nbsp;SecureHashAlgorithm new hashMessage: aString&quot; of the password used to protect them...</div>
<div><br></div><div>Anyway.... I do need encrypt/decrypt and it should be fast. I have just tried ARC4 and seems to be fast. I have a few questions:</div><div><br></div><div>- If I make the ARC4 key larger is it likely to be safer?&nbsp;</div>
<div>- How does ARC4 compare to blowfish from security point of view? Is blowfish much more secure or not that much?</div><div>&nbsp;</div><div>Thanks in advance!</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">If you are looking for a simple cypher for something other than a password how about ARC4 from <a href="http://www.squeaksrouce.com/Cryptography" target="_blank" class="vt-p">www.squeaksrouce.com/Cryptography</a> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">|key cText pText|<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">key := SecureRandom picker nextBits: 254. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">cText := (ARC4 new key: key) encrypt: &#39;This is a very secure but meaningless string&#39; asByteArray.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">pText := (ARC4 new key: key) decrypt: cText.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">^pText asString<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> &#39;This is a very secure but meaningless string&#39;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">It&rsquo;s pretty simple.&nbsp; To get the plainText back all you need is the key.&nbsp; <u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">All the best,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Ron Teitelbaum<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u>&nbsp;<u></u></span></p><div style="border-style:none none none solid;border-left-color:blue;border-left-width:1.5pt;padding:0in 0in 0in 4pt">
<div><div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in"><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Pharo-dev [mailto:<a href="mailto:pharo-dev-bounces@lists.pharo.org" target="_blank" class="vt-p">pharo-dev-bounces@lists.pharo.org</a>] <b>On Behalf Of </b>Mariano Martinez Peck<br>
<b>Sent:</b> Monday, February 17, 2014 4:17 PM<br><b>To:</b> Pharo Development List; <a href="mailto:glass@lists.gemtalksystems.com" target="_blank" class="vt-p">glass@lists.gemtalksystems.com</a>; The general-purpose Squeak developers list<br>
<b>Subject:</b> [Pharo-dev] FFI blowfish for encrypting / decrypting [WAS] Re: How to encrypt a password?<u></u><u></u></span></p></div></div><div><div class="h5"><p class="MsoNormal"><u></u>&nbsp;<u></u></p><div><div><p class="MsoNormal" style="margin-bottom:12pt">
<u></u>&nbsp;<u></u></p><div><p class="MsoNormal">On Thu, Nov 21, 2013 at 3:53 PM, Paul DeBruicker &lt;<a href="mailto:pdebruic@gmail.com" target="_blank" class="vt-p">pdebruic@gmail.com</a>&gt; wrote:<u></u><u></u></p><p class="MsoNormal">
Mariano Martinez Peck wrote<u></u><u></u></p><div><p class="MsoNormal">&gt; Hi Paul, and just to be sure I understand...none of them could work as a<br>&gt; two-way encryption, right?<br>&gt; The only one is your Pharo&#39;s version of Blowfish but that only works with<br>
&gt; 8<br>&gt; chars long. Is it like this? Or is there any other two-way encryption?<br>&gt;<br>&gt; Thanks!<br>&gt;<u></u><u></u></p></div><p class="MsoNormal" style="margin-bottom:12pt">&gt; --<br>&gt; Mariano<br>&gt; <a href="http://marianopeck.wordpress.com" target="_blank" class="vt-p">http://marianopeck.wordpress.com</a><br>
<br><br>Yes that&#39;s right. &nbsp;The PasswordHashingFFI stuff is all one way encryption.<br>Blowfish is two way, and the current implementation only works for 8 byte<br>chunks. &nbsp;I stopped working on it when the Smalltalk bcrypt implementation I<br>
wanted proved to be 5000x times slower than the FFI version. Someone needs<br>to add the CBC part to Blowfish to encrypt longer strings. &nbsp;I do not know of<br>another in image two way encryption scheme, but there may be something in<br>
the Cryptography repo. &nbsp;I&#39;m not sure.<br><br><u></u><u></u></p><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p></div><div><p class="MsoNormal">Hi Paul,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div><div><p class="MsoNormal">Sorry for the cross posting.&nbsp;<u></u><u></u></p></div><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p></div><div><p class="MsoNormal">I was using the Smalltalk version of the Blowfish you did to encrypt and decrypt things. But now I realize it is very very slow for the usage I need. You seem to have faced the same problem.&nbsp;<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p></div><div><p class="MsoNormal">I am encrypting pieces of 8 characters long. But I wonder if the <b>decryption</b> is available as well in FFI version? I see #ffiCrypt:with: &nbsp; but nothing to decrypt...<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p></div><div><p class="MsoNormal">Thanks in advance&nbsp;<u></u><u></u></p></div></div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div><p class="MsoNormal">-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank" class="vt-p">http://marianopeck.wordpress.com</a><u></u><u></u></p></div></div></div></div></div></div></div></blockquote>
</div><br><br clear="all"><div><br></div>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank" class="vt-p">http://marianopeck.wordpress.com</a><br>
</div></div>