Announcement

Collapse
No announcement yet.

addIdentity with key data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • addIdentity with key data

    We have to use javascript to implement SFTP in Mirth and we are trying to use below method.
    Also, We can't use file name approach in javascript as there are restriction.

    JSch addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase)
    Parameters:
    name - a name identifying the key pair.
    prvkey - the private key data. This will be zeroed out after creating the Identity object.
    pubkey - the public key data.
    passphrase - the passphrase necessary to access the private key.

    We have public and private keys but I am not sure how to convert those strings to byte[] prvkey and byte[] pubkey parameters in above method.

    We have tried below approach but generated the "Can't find method com.jcraft.jsch.JSch.addIdentity(string,java.lang. String,java.lang.String,java.lang.String)"
    var pubkey = "AAAAB3NzaC1yc2EAAAAD";
    var publickey = FileUtil.encode(new java.lang.String(pubkey).getBytes());

  • #2
    If pubkey is a base64 encoded string and you want to get an array of the bytes it represents, you want
    Code:
    var publickey = FileUtil.decode(pubkey);

    Comment

    Working...
    X