String hash to define unique filenames

Hi!
I'm writing a program and need to cache some resulting binary files for my users.  The binary filenames would change depending on the settings the user selects (so that the process of the unique settings are saved and later retrieved by the program).
I tried to use an md5 hash from some VIs used to generate the hash from a file to try and accomplish this.  The problem I had was that I found that subtle setting changes (switching a boolean from TRUE to FALSE, for instance) wouldn't generate a unique md5 result.  Something about the algorithm was only considering certain parts of my input string.
I started to dig through the code, but am not very experienced on md5 hashes.
In order to generate the hash i flatten and manipulate into strings all my controls that define the settings (for instance, an array of file names along with some boolean options on how to process the set of file names).  Then I concatenate all these strings together and supply this as input to my MD5 VI which spits out something like: acd3245h21543s that i add a .bin to the end of and use as a file name.  When the same string is supplied (i.e., the exact same settings are selected) the program sees that the binary "cached" file with the results already exists and uses that.  This doesn't work if I don't get unique strings for the file name, which is what I'm struggling with.
Thanks for all your input!

Nickerbocker wrote:
I tried to use an md5 hash from some VIs used to generate the hash from a file to try and accomplish this.  The problem I had was that I found that subtle setting changes (switching a boolean from TRUE to FALSE, for instance) wouldn't generate a unique md5 result.  Something about the algorithm was only considering certain parts of my input string.
Where does your MD5 VI come from? It's not the one shipped with LabVIEW or the OpenG solution. MD5 is not super strong like SHA-1 (or greater), but the string changing by the amount you mention should definitly trigger a new MD5 hash.
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!

Similar Messages

  • How to generate unique filenames??

    i need to be able to generate unique files from a servlet..
    my initial instinct was to use the seesion id as part of the filename, however as this file will be embedded in the responding html, this is not safe, as the user will only have to look at the html source to view a session id value.
    i am now considering to use the date/time of the creation of a session as the unique identifier for the file, however this will not work if two sessions can be created at the same time.
    my question thefore is if no two sessions can have the same date and time?
    if not.. can anyone give me an idea as how to produce unique filenames?

    If you are actually creating a file, why not usethe
    java.io.File.createTempFile() method?how does that help with prducing a unique value to use
    as the name of a file?
    with that method i still need to supply the filename
    as one of its arguments!
    No you don't. You provide a prefix and suffix and it fills in the middle with something guaranteed to be unique, in the directory you specify. Here is the javadoc:
    createTempFile
    public static File createTempFile(String prefix,
    String suffix,
    File directory)
    throws IOException
    Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. If this method returns successfully then it is guaranteed that:
    1. The file denoted by the returned abstract pathname did not exist before this method was invoked, and
    2. Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
    This method provides only part of a temporary-file facility. To arrange for a file created by this method to be deleted automatically, use the deleteOnExit() method.
    The prefix argument must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "hjb" or "mail". The suffix argument may be null, in which case the suffix ".tmp" will be used.
    To create the new file, the prefix and the suffix may first be adjusted to fit the limitations of the underlying platform. If the prefix is too long then it will be truncated, but its first three characters will always be preserved. If the suffix is too long then it too will be truncated, but if it begins with a period character ('.') then the period and the first three characters following it will always be preserved. Once these adjustments have been made the name of the new file will be generated by concatenating the prefix, five or more internally-generated characters, and the suffix.
    If the directory argument is null then the system-dependent default temporary-file directory will be used. The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "c:\\temp". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the the temporary directory used by this method.
    Parameters:
    prefix - The prefix string to be used in generating the file's name; must be at least three characters long
    suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
    directory - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
    Returns:
    An abstract pathname denoting a newly-created empty file
    Throws:
    IllegalArgumentException - If the prefix argument contains fewer than three characters
    IOException - If a file could not be created
    SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String) method does not allow a file to be created
    Since:
    1.2

  • How define unique constraint on many fields

    Hi,
    is there the possibility in kodo 4.1 to define unique constraint on many
    fields of a persistent class using orm mapping?
    I found the "unique" attribute to define on the field element, but it
    seams that this attribute cannot be define on may fields so that a
    unique combined index can be created.
    Any hint is welcome.
    Thank you very much.
    Daniela

    Unique constraint spanning multiple fields can be specified as follows:
    @Entity
    @Table(name="POBJECT", uniqueConstraints=
    {@UniqueConstraint(columnNames={"FIRST", "LAST"})})
    public class PObject {
    private String first;
    private String last;
    }

  • Can java create unique filenames?

    DataOutputStream out = new DataOutputStream(new FileOutputStream(fileName));
    String fileName = "c:/" + Integer.toString(stuff) + ".txt";
    out.write(stuff);
    The reason that this is important, is because I want to be able to create a unique filename each time I run the program (which records important data). I dont want the data overwritten within the same file over and over again.
    currently my program looks like this:
    DataOutputStream out = new DataOutputStream(new FileOutputStream("c:/data.txt"));
    out.write(stuff);
    each time I run the program however, the data.txt file will just get overwritten. How can I make my program resemble the one above without Java rejecting the codeing?

    I defer to DrClap - it does seem to work. Usingthe following codeimport java.io.*;
    public class Test {
        public static boolean createTempFile (String prefix, String suffix) {
            try {
                File.createTempFile(prefix, suffix);
            catch (IOException e) {
                return false;
            return true;
        public static void main( String [] args ) {
            System.out.println(Test.createTempFile("foo", "bar"));
            System.out.println(Test.createTempFile("bar", "foo"));
            System.out.println(Test.createTempFile("foo", "bar"));
    }I get files of the form
    fooNNNNNbar created. So my question is when would his EVER throw an IOException?

  • String hashing in Data Services

    Dear All,
    Is there a good and fast way for string hashing in Data Services? I would like to use it for table / multi !! column comparision. The reason is that comparision of large tables are a big problem for TC. It's a well proven concept and as we hash we can also store the hash value with the table for a next time... and the next.
    We are unfortunate not to have a Data Quality license, therefore a User Defined Transform with (for example) a Python script is not one of the possibilities.
    DBMS_SQLHASH on Oracle and import as function didn't do the trick (to slow in Oracle) and as we have free processor capacity on data services....
    Formerly I have done this with a native MD5 function in Powercenter and SSIS, but in BODS it seems to be a little difficult.
    Might you have any suggestions? I hope to read your creative solutions ;-)
    Thanks in advance for answering!

    Hi,
     Darren Gosbell wrote:
    Have you see this site? http://www.sqlserveranalysisservices.com
    It has a couple of links on the lower left that discuss various cell annotation approaches in more detail than the discussion in this thread.
    Thanks, following the article "More on cell annotation" I have been able to have String Measures.
    a+, =)
    -=Clément=-

  • Using dataexport in a business rules and define the filename with a sub var

    Hi,
    I have created a calc script to export data using DATAEXPORT, and to define the filename an essbase variable.
    Here all right
    I copy this code to a business rules to run it from a business rules, but I have a problem with the essbase variable, when I validate it, it gives me the error:
    Detail:Encountered "&FileNm" at line 28, column 26.
    Was expecting:
    My essbase variable is set to:
    "e:\Hyperion\products\Essbase\EssbaseServer\app\TMPGB\dataexportCustomerY2.txt"
    in double quote
    How anyone use in a Business rules with the command dataexport an essbase substitution variable

    Just tried:
    Script: DATAEXPORT "File" " " &Filename "#Missing";
    SubsVar: "c:\DataExtract.txt"
    it worked with no issues.
    Cheers,
    Alp

  • XFA form with button to save file with unique filename

    Is there a way to save a file with a unique filename using some data a user has entered (name, for ex.) that will fire when the user clicks a Print button? Attached is a file for reference.

    Yes, I'm getting close. With this
    var 
    vTargetName = Page1.dateStamp.rawValue + " HSS Foot & Ankle for Patient " + Page1.First_Name.rawValue + " " + Page1.MI.rawValue + " " + Page1.Last_Name.rawValue + ".pdf";
    var  
    vCurrentName = event.target.documentFileName.toString(); 
    if  
    (vCurrentName == vTargetName)app.alert("Thank you. Your form has been saved."); 
    else
    app.alert("There was a problem. Your form has not been saved.");
    I do get an alert when the PDF is saved. But if I modify the folder js to say var vPath = "/c/HSS/ instead of var vPath = "/c/HSSSave/ I don't get the alert "There was a problem." Do you see an error in the else condition?

  • Why String class is defined as immutable?

    Why String class is defined as immutable? what can be the reason behind it?

    Do try this at home. :)
    public class Main {
        public static void main(String... args) {
            System.out.println("Greetings.");
            System.out.println("Goodbye.");
        static {
            // translates into Japanese. NOT a good idea!
            try {
                final Field field = String.class.getDeclaredField("value");
                field.setAccessible(true);
                char[] chars = new char[8];
                "Sayonara".getChars(0,8,chars,0);
                field.set("Goodbye.", chars);
                chars = new char[10];
                "Konichi-wa".getChars(0,10,chars,0);
                field.set("Greetings.", chars);
            } catch (Exception e) {
                throw new AssertionError(e);
    }

  • Any way to get unique filename in "Save as" dialog?

    is there any kind of 3rd-party add-on or whatever that would give an option in the "Save as" dialog to simply make up a file name that would be unique in whatever folder it's trying to save to?
    Mike

    Kappy wrote:
    Do you mean to automatically insert a filename for you in the Save As: field of the dialog? Why is that needed when the field is usually always in a selected state so you can enter a filename of your choice? Maybe I don't quite understand what you are asking.
    ok. Suppose I am downloading files from an on-line web archive where many of the files have the same name. This means that for each one, I have to modify the name manually in the Save As: field, so they don't overwrite each other when I'm saving to a folder on my local hard drive. I certainly can enter new names for each, but it gets very tedious when there are a lot of files. I was wondering if there's any 3rd-party software that puts an extra option on there to automatically save with a unique name.
    thanks,
    Mike

  • Exporting a multipage InDesign document to single page PDFs but with unique filenames using scripts

    Hi,
    I'm using InDesign 5.5.
    My goal is to export a multipage InDesign file into single page PDFs but each single PDF must be uniquely named.
    For example;
    InDesignFileName_487275123.00.pdf
    InDesignFileName_734876882.00.pdf
    ...and so on.
    I've spent a great deal of time searching online and the closest I have found is  software called Output Factory which works fine.
    The way Output Factory works is by placing a script label within a textframe on the master page in InDesign. Then whatever is typed into the text frame on each the separate pages defines the file name of each separate page.
    However if I can solve this problem without any investment costs my boss will be very happy
    I found PEU5 which works great for exporting into single pages, it's now a case of naming each single PDF but I know nothing how about to create a script but I get the gist of what they do. My understanding is that a script could solve the second half of my problem.
    Can anyone help?
    Thanks.
    S

    Thanks Peter but but I don't think this is what I'm looking for.
    I did find this post http://forums.adobe.com/thread/841982 but I can't seem to get the script to work.
    This is the error message I get when I run the script... any ideas what I'm doing wrong?

  • Defined FTP filename but no working....

    Hi, Experts,
    I try to name the target filename but always no working....
    Please kindly help to check anything wrong with my codes & setting,
    many many thanks~
    The format of intended file name is "A1111-" + ID + ".XML"
    For Example: YC101-434729844234234.xml
    (The content if ID is from a field of source RFC structure)
    Therefore, I create a UDF with an argument "var1" with java code as below
    Public String Calculate(String var1, Container container) throws StreamTransformationException{
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String MyFileName = "YC101-" + var1 + ".xml";
    conf.put(key, MyFileName);
    return MyFileName;
    I also did the setting for File Receiver Adapter as below:
    Under Target Tab
    File Name Scheme: abc.xml
    Under Processing Tab
    File Construction Mode: Create
    File Type: Binary
    Under Advanced Tab
    Adapter-Specific Message Attributes
    Tick Use Adapter-Specific Message Attributes
    Tick File Name
    Anything insufficient with my works??
    E.D

    Hi, Experts,
    When I set my file name from abc.xml to *,
    I got an error message from runtime workbench as below:
    File processing failed with com.sap.exception.standard.SAPIllegalArgumentException:
    The parameter "argument" has the value "remote:///test/*", so it contains the character
    "remote:///test/*" which is not allowed
    Btw, The target directory (under Target tab) what I set is /test...
    But for my case,
    the argument "var1" I supposed should be the content of ID (A field of source RFC structure);
    for example, the content of ID is 665329478934;
    my intended target file name will be A1111-665329478934.xml (format: "A1111" + ID + ".xml")
    Any more suggestions??
    Thanks in advance~
    E.D

  • Strings comparision and get unique string in pure sql,

    Dear all,
    Here is two strings
    S1='A,B,C,D,F';
    s2='C,F,H,B,A,K';
    output should be like unique string values ..
    S3= A,B,C,D,F,H,K;
    How to get this in pure sql..
    thanks in advance,
    Roots

    Hi,
    In a relational database, each column of each row should store one value, not a repleating group of values, such as a delimited list. This is so basic to database design that it is called "First Normal Form". You don't have to follow rules like this, but, if you don't, your code will be complicated, inefficient, and error-prone. It sould be best to re-design your application so that each value was on a separate row.
    If you can't do that, then you can start by splitting your delimitd lists into separate rows. Then you can easily fond the distinct values, and use any String Aggregation technique to combine the results into one output row.
    Here's one way to do all that:
    WITH     got_params     AS
         SELECT     'A,B,C,D,F' AS str, 1 AS str_id     FROM dual     UNION ALL
         SELECT     'C,F,H,B,A,K',          2            FROM dual
    ,     got_part_cnt     AS
         SELECT     str
         ,     1 + LENGTH (str)
                - LENGTH (REPLACE (str, ','))     AS part_cnt
         FROM    got_params
    ,     cntr          AS
         SELECT     LEVEL     AS n
         FROM     (
                  SELECT  MAX (part_cnt)     AS max_part_cnt
                  FROM    got_part_cnt
         CONNECT BY     LEVEL     <= max_part_cnt
    ,     got_substr     AS
         SELECT DISTINCT
                REGEXP_SUBSTR ( p.str
                               , '[^,]+'
                        , 1
                        , c.n
                        )          AS sub_str
         FROM    got_part_cnt p
         JOIN     cntr          c  ON     c.n     <= p.part_cnt
    ,     got_r_num     AS
         SELECT     sub_str
         ,     ROW_NUMBER () OVER (ORDER BY  sub_str)     AS r_num
         ,     ROWNUM                                        AS r
         FROM     got_substr
    SELECT     MIN ( SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
                          , 2
             )          AS unique_sub_strs
    FROM    got_r_num
    WHERE     CONNECT_BY_ISLEAF     = 1
    -- START WITH     r_num     = 1
    CONNECT BY     r_num     = 1 + PRIOR r_num
    ;This works in Oracle 10.2.0.2.0 Express Edition, which is the only database I can use right now. For the main query, you should be able to say:
    SELECT     SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
                , 2
                )     AS unique_sub_strs
    FROM    got_r_num
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     r_num     = 1
    CONNECT BY     r_num     = 1 + PRIOR r_num
    ;but, when I try that on my database, I only get 'A,B' as the output. CONNECT BY is very buggy in Oracle 10.2; if you have Oracle 10.1, the simpler form might work.
    The query above can be shortened some, but I wrote it this way to make it easier to understand.
    You can, for example, combine the sub-queries got_sub_str and got_r_num. If you do, use DENSE_RANK instead of ROW_NUMBER.
    This does not assume that the sub-qtrings are all 1-character long. If they are, then the query can be simplified.
    For more about string aggregation, see
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • How to create placeholder garphics with unique filenames shown as text?

    I need to create quite a few placeholder graphics, which are all the same
    size and background colour, and which show the filename of the graphic as
    text in the graphic. Later each will be replaced.
    I have the filename list but am not sure how I would automate this process?

    There is already a Script for that. AddFileName and AddFileName Plus Date. If they are not in your Scripts folder alreagy, they are available on the Adobe Exchange I believe.

  • Create unique filename by auto-incre​ment path

    I needed a program that would take in a pathname, see if the file name already existed at that location, and if so it needed to auto-increment the file name. I wanted it to work the way windows inherently does when you copy a file of the same name into a location because that seems the most natural to me. I was running into problems with the ftp functions in the internet toolkit becaues if the local file already exists at the path you input, it just doesn't perform the get files function.
    I discovered after searching the forums that a lot of people run into this all the time and usually the way they get a unique file name is by adding the date and time to the end of the file. This is both effective and informative, but results in unnecessarily long and ugly file names. 
    So I made a subVI and I wanted to share it with you guys. Hope someone finds it useful. Let me know what you think.
    [will work for kudos]
    Attachments:
    Unique File Name.vi ‏34 KB

    I took your suggestions
    - appended (T) to the check existence input description to indicate its default position
    - Created a "New Path?" output that idicates whether a new path was created (T) or if the inputted path was simply passed through (F)
    And for all the users who dont have 2009... Here are some older versions for you
    enjoy
    [will work for kudos]
    Attachments:
    Unique File Name.vi ‏35 KB
    Unique File Name_8-5.vi ‏44 KB
    Unique File Name8-6.vi ‏35 KB

  • Looking for a script that will size photos down and give unique filenames

    Here's the challenge:
    I have a bunch of photos that need to be sized down to three different types of thumbnails, each group of thumbnails needs to have a specific prefix to the filename while keeping the rest of filename in tact.
    So example:
    I start out with a photo 1400 x 933
    That photo needs to be sized down to 3 different smaller sizes: 630 x 420, 210 x 140 and 140 x93 (all of those have the same aspect ratio as 1400 x 933). So far this is a simple Action in Photoshop.
    The trick I can't figure out is that these photos need to have a specific file naming convention. Say for example the 1400 x 933 photo we start out with is named w_paul_001.jpg the other photos once sized down need to be: x_paul_001.jpg (for the 630x420), y_paul_001.jpg (for the 210 x 140) and z_paul_001.jpg (for the 140x93).
    How I do dat?

    This will do what you want:
    var srcDoc = app.activeDocument;
    var imgNum = srcDoc.name.substring(7, (srcDoc.name.length)-4);
    var myJpgQuality = 12
    var sizeArray = [
    [1400, 933, "x_paul_"],
    [630,  420, "y_paul_"],
    [100,  100, "z_paul_"]
    for (var i=0; i<sizeArray.length; i++)
      var shrinkWidth =  sizeArray [i][0];
      var shrinkHeight = sizeArray [i][1];
      var mySaveName = sizeArray [i][2];
      var id428 = charIDToTypeID( "Dplc" );
      var desc92 = new ActionDescriptor();
      var id429 = charIDToTypeID( "null" );
      var ref27 = new ActionReference();
      var id430 = charIDToTypeID( "Dcmn" );
      var id431 = charIDToTypeID( "Ordn" );
      var id432 = charIDToTypeID( "Frst" );
      ref27.putEnumerated( id430, id431, id432 );
      desc92.putReference( id429, ref27 );
      var id433 = charIDToTypeID( "Nm  " );
      desc92.putString( id433, mySaveName );
      executeAction( id428, desc92, DialogModes.NO );
      activeDocument.resizeImage(shrinkWidth, shrinkHeight, 72, ResampleMethod.BICUBIC);
      filePath = srcDoc.path + '/' + mySaveName + imgNum + '.jpg';
      var jpgFile = new File(filePath);
      jpgSaveOptions = new JPEGSaveOptions();
      jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
      jpgSaveOptions.embedColorProfile = true;
      jpgSaveOptions.matte = MatteType.NONE;
      jpgSaveOptions.quality = myJpgQuality;
      activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

Maybe you are looking for

  • How do i sync my iphone with a new computer

    I recently purchased a new iMac and would like to sync my iphone (and iPad) with the new computer. I was previously using a mac book and I thought it would be as easy as just plugging the phone in to my new computer, but from what I have been able to

  • Internet signal but no Windows XP internet connection

    I have a MacPro partitioned using BootCamp and can access the internet using the Mac OS side but when I open to the Windows XP partition, I have an "excellent" signal denoted in the lower right hand corner but can not get a connection to the internet

  • Create an output without the sql commands

    Hi, i have the following procedure: CREATE OR REPLACE PROCEDURE test IS BEGIN DBMS_OUTPUT.PUT_LINE('HI EVERYONE'); END test; SET serveroutput ON; SET pagesize 500 ; SET linesize 200 ; SET heading off ; SET echo off; spool test.html; exec test; spool

  • MS Outlook Layout

    Hi All, I'm new to Flex. And my GUI background is delphi and .NET winforms. I was tring to do what is very simple in those environments. recreate the MS Outllook layout. That is: Treeview on the left and to panles on the right with a resizing bar bet

  • Whole number rounding off in bom

    is it possible not to round off whole numbers in the bom component quantity? for example, when i input the number 8.000, the system rounds it off to just 8.