Вообщем решил не парить мозг и сделать все тупо:)
Вот решение если кому нужно:
C++ (Qt)
QString MainWindow::hex(QString str) {
QString chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_,.()[]{}<>~!@#$%^&*+=?";
QStringList hexstr;
QString fn;
int i, he;
hexstr <<"41"<<"42"<<"43"<<"44"<<"45"<<"46"<<"47"<<"48"<<"49"<<"4a"<<"4b"<<"4c"<<"4d"<<"4e"
<<"4f"<<"50"<<"51"<<"52"<<"53"<<"54"<<"55"<<"56"<<"57"<<"58"<<"59"<<"5a"<<"61"<<"62"
<<"63"<<"64"<<"65"<<"66"<<"67"<<"68"<<"69"<<"6a"<<"6b"<<"6c"<<"6d"<<"6e"<<"6f"<<"70"
<<"71"<<"72"<<"73"<<"74"<<"75"<<"76"<<"77"<<"78"<<"79"<<"7a"<<"31"<<"32"<<"33"<<"34"
<<"35"<<"36"<<"37"<<"38"<<"39"<<"30"<<"2d"<<"5f"<<"1f"<<"2e"<<"28"<<"29"<<"5b"<<"5d"
<<"7b"<<"7d"<<"3c"<<"3e"<<"7e"<<"21"<<"40"<<"23"<<"24"<<"25"<<"5e"<<"26"<<"2a"<<"2b"
<<"3d"<<"3f";
for (i=0; i < str.size(); ++i){
he = chars.indexOf(str[i]);
if ( he >= 0) {
fn = fn + hexstr[he];
fn = fn + " ";
}
}
return fn;
}