Code: Select all
put fld "Field_baseURL" into myVar
put fld "Field_keyCode" after myVar
like this
a b
The result needs to be ab
any idea or suggestion is always good, thanks in advance.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
put fld "Field_baseURL" into myVar
put fld "Field_keyCode" after myVar
Good point, I have done that, apparently it is a result of decoding some encrypted text, so some other option is needed to get rid of that extra space.dunbarx wrote:Looking at your example, it seems you must have a space after the first field, or before the second. You can always just delete those spaces, or better, try to find out why they are included when the field is populated.
Code: Select all
put field "keytext" into kkey
put the text of field "codet" into codetext
put Blowfish_Decode_string(codetext, kkey) into field "decode"
Code: Select all
put the replaceText ("a ", " $", "") into myVar -- a is followed by four spaces
put "b" after myVar
put myVar
Result
a b -- only 3 spaces between a and b
Code: Select all
put word 1 to -1 of fld "theFirstField" into fld "theSecondField"
Interesting, thanks for your post, very useful, as always all input is much appreciated,dickey wrote:Hello realstuff,
Whether preceding or trailing spaces (spaces at the beginning or end of your variables, fields, or strings) the best way to trim them I know is code similar to this.
the string " realstuff rocks " will trim to "realstuff rocks";Code: Select all
put word 1 to -1 of fld "theFirstField" into fld "theSecondField"
the string "realstuff rocks " will trim to "realstuff rocks";
the string " realstuff rocks" will again trim to "realstuff rocks".
It will trim multiple whitespace chars like spacespace.
I hope that helps.
Kind regards, Andrew
Code: Select all
function Blowfish_decode_string t, key
# Given the codetext message t and the decoding/encoding key, the original plaintext is reconstructed
If Blowfish_lastkey <> key then Blowfish_Init key -- caller wants a change of keys, so re-initialize the S[] and PP[] arrays
put the length of t into tle -- how many character bytes does t hold?
# Determine how many round of decoding need to be done
put tle div 16 into full -- how many chunks of 16-byte hex codes are to be processed
put tle mod 16 into partly -- rest of the character bytes
put full - 1 into final
if partly > 0 then put full into final
put "" into rresultat -- rresultat will hold the plaintext message
repeat with block = 0 to final
put block * 16 into tle
put (character tle +1 to tle + 8 of t) into inter -- intermediate storage
put hex_to_decimal(inter) into dl
put (character tle + 9 to tle + 16 of t) into inter
put hex_to_decimal(inter) into dr
put BFdec(dl, dr) into inter -- decoded plaintext
put inter[0] into dl
put inter[1] into dr
put decimal_to_four_letters(dl) into dl
put decimal_to_four_letters(dr) into dr
put rresultat & dl & dr into rresultat
end repeat
return rresultat
end Blowfish_decode_string
Thank you, yes, I can see, that at least I think I do, so I need to examine the Hex values,Peter Wood wrote:The additional characters at the end of the decrypted plain text would seem to stem from the padding characters that will have been added to the source plain text. I couldn't see where you remove any padding in your code.
The most common padding method uses the following pattern (all in hexadecimal)
Hex "01" - 1 byte of padding
Hex "0202" - 2 bytes of padding
.
.
Hex "07070707070707" - 7 bytes of padding.
Hope this helps.
Peter
Code: Select all
put "Hello" into tPlain
put ("" & the length of tPlain) into lenPlaintext
put lenPlaintext & "a" & tPlain into tPlain
put Blowfish_encode_string(tPlain, "somekey") into tCiphertext
answer "Hello" & return & tPlain & return & tCiphertext
put "" into tPlain
Code: Select all
put "" into tPlain -- forget the old plaintext
put Blowfish_decode_string(tCiphertext, "somekey") into tPlain
put matchChunk(tPlain, "(a)", firstOccurence, lastOccurence) into pFound
put (char 1 to (firstOccurence - 1) of tPlain) * 1 into lenPlaintext
put (char (firstOccurence + 1) to the length of tPlain of tPlain) into tPlain
if the length of tPlain > lenPlaintext then put (char 1 to lenPlaintext of tPlain) into tPlain
answer tCiphertext & return & lenPlaintext & return & tPlain