首页  编辑  

字符串异或运算

Tags: /C#/字符串处理/   Date Created:

private string StringXor( string Str , string Key )

{

    int vKeyLen = Key . Length;

    char [] StrChars = Str . ToCharArray();

    char [] KeyChars = Key . ToCharArray();

    int j = 0 ;

    for ( int i = 0 ; i < Str . Length; i ++ )

       StrChars[i] ^= KeyChars[j ++ % Key . Length];

    return new string(StrChars);

}