For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

beefy80's avatar
beefy80
Icon for Nimbostratus rankNimbostratus
Jun 05, 2014

Convert string with parity to standard ASCII

Hello

 

I need to convert a string that has Even Parity added to it to printable ascii. However I am having problems in getting this working. Can anyone advise on how to achieve this in an iRule.

 

Thanks

 

James

 

2 Replies

  • James_Deucker_2's avatar
    James_Deucker_2
    Historic F5 Account

    Here's the TCL that will do the encode

    set plain_str "james was here ok"
    puts "Plain String '$plain_str'"
    set even_parity ""
    foreach c [split $plain_str ""] { append even_parity [format %c [expr { ( [scan $c %c] & 127 ) + (!([scan $c %c] & 1)<<7)}]]}
    puts "Even Parity '$even_parity'"
    

    And here's the decode:

    set stripped_parity ""
    foreach c [split $even_parity ""] { append stripped_parity [format %c [expr {[scan $c %c] & 127}]]}
    puts "Stripped Parity '$stripped_parity'"
    

    Output:

    Plain String 'james was here ok'
    Even Parity 'êames was èeòe ok'
    Stripped Parity 'james was here ok'
    
  • James, Thank you for this I have been trying all sorts of variations to resolve this I wasn't far off getting it right either. Thanks again.