我用加密算法加密字符串,
把加了密的字符串插入数据库,
有时插入正常,有时出错:字符串***之前有未闭合的引号。我用字符代替函数:
        password:=StringReplace(password,'''','o',[rfReplaceAll]);
        password:=StringReplace(password,'(','o',[rfReplaceAll]);
        password:=StringReplace(password,')','o',[rfReplaceAll]);
        password:=StringReplace(password,',','o',[rfReplaceAll]);
        password:=StringReplace(password,';','o',[rfReplaceAll]);
有时还是不行。

解决方案 »

  1.   

    function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
      

  2.   

    加了密的字符串插入数据库?
    经过Base64编码以后就一定没有问题
    Indy就可以做到
      

  3.   

    一个稳健的方法:加密后的字符串全部转换成16进制字符串。
    如:ABCD转换成:41424344
    稳如泰山。
    http://www.csdn.net/cnshare/soft/12/12825.shtm