请高手帮我看看,为什么我解密不出来,asp加密的,我用C#解密出现了点小问题
程序代码:
Function StrDecode(byval str) dim base64 : set base64 = new base64_class LenStr=len(str) str=StrReverse(str) str=mid(str,int(LenStr/2)+1) & mid(str,1,int(LenStr/2)) base64.bstr = "ABCDEF1234GHIJKLMnopqrs+tuvwxyz09abcdef!ghijklmNOPQRS5678TUVWXYZ" base64.blen = 16 str = base64.decode(str) set base64 = nothing StrDecode = str End function
这个是C#版
程序代码:
public static string Decode64(string str) { String Str = String.Empty; foreach (var item in str.Reverse()) { Str += item; } Str = (Str.Substring((Str.Length / 2) + 1) + Str.Substring(1, (Str.Length / 2))); str = Str; string Base64Code = "ABCDEF1234GHIJKLMnopqrs+tuvwxyz09abcdef!ghijklmNOPQRS5678TUVWXYZ"; int page = str.Length / 4; System.Collections.ArrayList outMessage = new System.Collections.ArrayList(page * 3); char[] message = str.ToCharArray(); for (int i = 0; i < page; i++) { byte[] instr = new byte[4]; instr[0] = (byte)Base64Code.IndexOf(message[i * 4]); instr[1] = (byte)Base64Code.IndexOf(message[i * 4 + 1]); instr[2] = (byte)Base64Code.IndexOf(message[i * 4 + 2]); instr[3] = (byte)Base64Code.IndexOf(message[i * 4 + 3]); byte[] outstr = new byte[3]; outstr[0] = (byte)((instr[0] << 2) ^ ((instr[1] & 0x30) >> 4)); if (instr[2] != 64) { outstr[1] = (byte)((instr[1] << 4) ^ ((instr[2] & 0x3c) >> 2)); } else { outstr[2] = 0; } if (instr[3] != 64) { outstr[2] = (byte)((instr[2] << 6) ^ instr[3]); } else { outstr[2] = 0; } outMessage.Add(outstr[0]); if (outstr[1] != 0) outMessage.Add(outstr[1]); if (outstr[2] != 0) outMessage.Add(outstr[2]); } byte[] outbyte = (byte[])outMessage.ToArray(Type.GetType("System.Byte")); return System.Text.Encoding.Default.GetString(outbyte); }
[ 本帖最后由 sixserve 于 2010-11-7 08:14 编辑 ]