It is worse. crypt() encrypts only the first 8 characters, so that any (file)names with the same 8 starting chars encrypt to the same string (given the same seed). Also you don't get 13 chars out of it, but 11, because the first to characters are the preselected seed. You could use 2 characters of your filename as seed, but then you would give an attacker already two known characters of the filename for free

You might look at other hash algorithms, for example Digest::MD5 or Digest::SHA2. Base64 encoded you still get '/' in the hash, but you could afterwards use tr{/}{-} to change every / into a -

You do know that hash functions are one-way, right? You can't decrypt those filenames later on, not with crypt nor any of the hashes I mentioned. If you need to decrypt them again you have to use a symmetric chiffre like DES or AES

If you need a better answer, tell us more


In reply to Re: best way to encrypt long file names? by jethro
in thread best way to encrypt long file names? by keiusui

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.