[Plugins-writers] converting hex to ascii

From: dave@private
Date: Tue Mar 09 2004 - 20:15:45 PST

  • Next message: Michel Arboi: "Re: [Plugins-writers] converting hex to ascii"

    I'm working with a string created with hexstr(). I've done some work on the hex values, now I want to convert back to ASCII. Say I have a string "4c444150",is there function available to convert back to ASCII? Maybe I missed something in the NASL2 ref?
    
    Also, I've made an effort to perform the conversion by incrementing through a string by twos and preceding the characters with \x. However, the following code snip will produce \x4c\x44\x41\x50, not the ASCII string "LDAP" as I would like.
    
    For example:
    
    version = "4c444150";
    i = 0;
    f = 1;
    while (f <= strlen(version)) {
    x = version[i];
    y = version[f];
    z =  string("\x" + x + y);
    conv = string(z); 
    display(conv);
    i = i + 2;
    f = f + 2;
    }
    
    --> displays \x4c\x44\x41\x50
    
    
    This will display the ASCII values however.
    
    a = "\x4c\x44\x41\x50";
    b = string(a);
    display(b, "\n");
    
    --> displays LDAP
    
    What am I doing wrong?
    
    -dave 
    _______________________________________________
    Plugins-writers mailing list
    Plugins-writers@private
    http://mail.nessus.org/mailman/listinfo/plugins-writers
    



    This archive was generated by hypermail 2b30 : Tue Mar 09 2004 - 19:37:14 PST