本文整理匯總了C#中Tamir.SharpSsh.jsch.JSch.getConfig方法的典型用法代碼示例。如果您正苦於以下問題:C# JSch.getConfig方法的具體用法?C# JSch.getConfig怎麽用?C# JSch.getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tamir.SharpSsh.jsch.JSch
的用法示例。
在下文中一共展示了JSch.getConfig方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: getFingerPrint
public String getFingerPrint(JSch jsch){
HASH hash=null;
try{
hash=(HASH)Activator.CreateInstance(Type.GetType(jsch.getConfig("md5")));
}
catch(Exception e){ Console.Error.WriteLine("getFingerPrint: "+e); }
return Util.getFingerPrint(hash, key);
}
示例2: test
public static void test()
{
JSch jsch = new JSch();
DH dh1 = null;
DH dh2 = null;
try
{
Type t=Type.GetType(jsch.getConfig("dh"));
dh1=(DH)(Activator.CreateInstance(t));
dh1.init();
dh2=(DH)(Activator.CreateInstance(t));
dh2.init();
}
catch(Exception ee)
{
Console.WriteLine(ee);
}
dh1.setP(DHG1.p);
dh1.setG(DHG1.g);
dh2.setP(DHG1.p);
dh2.setG(DHG1.g);
// The client responds with:
// byte SSH_MSG_KEXDH_INIT(30)
// mpint e <- g^x mod p
// x is a random number (1 < x < (p-1)/2)
byte[] e=dh1.getE();
byte[] f=dh2.getE();
Console.WriteLine("Private1 = {0}", hex(e));
Console.WriteLine();
Console.WriteLine("Private2 = {0}", hex(f));
Console.WriteLine();
dh1.setF(f);
dh2.setF(e);
byte[] k1 = dh1.getK();
byte[] k2 = dh2.getK();
Console.WriteLine("Public1 = {0}", hex(k1));
Console.WriteLine();
Console.WriteLine("Public2 = {0}", hex(k2));
Console.WriteLine();
}
示例3: IdentityFile
internal IdentityFile(String identity, JSch jsch)
{
this.identity=identity;
this.jsch=jsch;
try
{
Type c=Type.GetType(jsch.getConfig("3des-cbc"));
cipher=(Cipher)Activator.CreateInstance(c);
key=new byte[cipher.getBlockSize()]; // 24
iv=new byte[cipher.getIVSize()]; // 8
c=Type.GetType(jsch.getConfig("md5"));
hash=(HASH)(Activator.CreateInstance(c));
hash.init();
FileInfo file=new FileInfo(identity);
FileStream fis = File.OpenRead(identity);
byte[] buf=new byte[(int)(file.Length)];
int len=fis.Read(buf, 0, buf.Length);
fis.Close();
int i=0;
while(i<len)
{
if(buf[i]=='B'&& buf[i+1]=='E'&& buf[i+2]=='G'&& buf[i+3]=='I')
{
i+=6;
if(buf[i]=='D'&& buf[i+1]=='S'&& buf[i+2]=='A'){ type=DSS; }
else if(buf[i]=='R'&& buf[i+1]=='S'&& buf[i+2]=='A'){ type=RSA; }
else if(buf[i]=='S'&& buf[i+1]=='S'&& buf[i+2]=='H')
{ // FSecure
type=UNKNOWN;
keytype=FSECURE;
}
else
{
//System.out.println("invalid format: "+identity);
throw new JSchException("invaid privatekey: "+identity);
}
i+=3;
continue;
}
if(buf[i]=='C'&& buf[i+1]=='B'&& buf[i+2]=='C'&& buf[i+3]==',')
{
i+=4;
for(int ii=0; ii<iv.Length; ii++)
{
iv[ii]=(byte)(((a2b(buf[i++])<<4)&0xf0)+
(a2b(buf[i++])&0xf));
}
continue;
}
if(buf[i]==0x0d &&
i+1<buf.Length && buf[i+1]==0x0a)
{
i++;
continue;
}
if(buf[i]==0x0a && i+1<buf.Length)
{
if(buf[i+1]==0x0a){ i+=2; break; }
if(buf[i+1]==0x0d &&
i+2<buf.Length && buf[i+2]==0x0a)
{
i+=3; break;
}
bool inheader=false;
for(int j=i+1; j<buf.Length; j++)
{
if(buf[j]==0x0a) break;
//if(buf[j]==0x0d) break;
if(buf[j]==':'){inheader=true; break;}
}
if(!inheader)
{
i++;
encrypted=false; // no passphrase
break;
}
}
i++;
}
if(type==ERROR)
{
throw new JSchException("invaid privatekey: "+identity);
}
int start=i;
while(i<len)
{
if(buf[i]==0x0a)
{
bool xd=(buf[i-1]==0x0d);
Array.Copy(buf, i+1,
buf,
i-(xd ? 1 : 0),
len-i-1-(xd ? 1 : 0)
);
if(xd)len--;
len--;
continue;
//.........這裏部分代碼省略.........