(PureBasic) SSH Key Fingerprint
Generates a fingerprint for an SSH key.
IncludeFile "CkSshKey.pb"
Procedure ChilkatExample()
key.i = CkSshKey::ckCreate()
If key.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Load an SSH key from an encrypted OpenSSH-formatted private key:
CkSshKey::setCkPassword(key, "secret")
keyStr.s
; First load the PEM into a string:
keyStr = CkSshKey::ckLoadText(key,"privkey_openssh_encrypted.pem")
; Import into the SSH key object:
success = CkSshKey::ckFromOpenSshPrivateKey(key,keyStr)
If success <> 1
Debug CkSshKey::ckLastErrorText(key)
CkSshKey::ckDispose(key)
ProcedureReturn
EndIf
; Generate the fingerprint:
fingerprint.s
fingerprint = CkSshKey::ckGenFingerprint(key)
Debug fingerprint
; 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
CkSshKey::ckDispose(key)
ProcedureReturn
EndProcedure
|