c# 和 delphi 的 base64 编码一致问题 webservice
c# 和 delphi 的 base64 编码一致问题 webservice
1 delphi部分:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,EncdDecd;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var s:AnsiString;
begin
s:=edit1.text;
edit2.Text:= EncodeString((s));
// 超越软件 http://www.cyhlw.com
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit3.Text:=DecodeString(edit2.text)
end;
end.
2c# 部分:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.ContentEncoding = System.Text.Encoding.GetEncoding( "GB2312" );
}
protected void Button1_Click(object sender, EventArgs e)
{
string str="";
localhost.IIHelloservice oserver = new localhost.IIHelloservice();
str=oserver.sayHello("超越软件 http://www.cyhlw.com");
//localhost.WebService1 oService = new localhost.WebService1();
//Label1.Text = oService.About();
this.TextBox1.Text = str;
byte[] bytes = System.Convert.FromBase64String(str);
str = "";
str = Encoding.Default.GetString(bytes);
TextBox2.Text = str;
//TextBox1.Text=Encoder.get
//byte[] bytes
//this.TextBox1.Text = System.Convert.FromBase64String(str);
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。