Sample code for 30+ languages & platforms
DataFlex

SSH Key Fingerprint

See more SSH Key Examples

Generates a fingerprint for an SSH key.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoKey
    String sKeyStr
    String sFingerprint
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatSshKey)) To hoKey
    If (Not(IsComObjectCreated(hoKey))) Begin
        Send CreateComObject of hoKey
    End

    // Load an SSH key from an encrypted OpenSSH-formatted private key:
    Set ComPassword Of hoKey To "secret"

    // First load the PEM into a string:
    Get ComLoadText Of hoKey "privkey_openssh_encrypted.pem" To sKeyStr

    // Import into the SSH key object:
    Get ComFromOpenSshPrivateKey Of hoKey sKeyStr To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoKey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Generate the fingerprint:

    Get ComGenFingerprint Of hoKey To sFingerprint

    Showln sFingerprint

    // A sample fingerpring looks like this:
    // ssh-dss 2048 d0:5f:f7:d6:49:60:7b:50:19:f4:41:59:d4:1f:61:7


End_Procedure