Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Password_Digest = Base64 (SHA-1 ( nonce + created + SHA-1 (password) ) )Demonstrates how to compute: Password_Digest = Base64 (SHA-1 ( nonce + created + SHA-1 (password)))
integer li_rc string ls_Password oleobject loo_Crypt oleobject loo_Prng oleobject loo_Bd oleobject loo_Dt string ls_Created string ls_PasswordSha1 string ls_PasswordDigest // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. ls_Password = "secret" loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") if li_rc < 0 then destroy loo_Crypt MessageBox("Error","Connecting to COM object failed") return end if loo_Crypt.HashAlgorithm = "SHA-1" loo_Crypt.EncodingMode = "base64" // Generate a 16-byte random nonce loo_Prng = create oleobject // Use "Chilkat_9_5_0.Prng" for versions of Chilkat < 10.0.0 li_rc = loo_Prng.ConnectToNewObject("Chilkat.Prng") loo_Bd = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData") loo_Prng.GenRandomBd(16,loo_Bd) // Get the current date/time in a string with this format: 2010-06-08T07:26:50Z loo_Dt = create oleobject // Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime") loo_Dt.SetFromCurrentSystemTime() ls_Created = loo_Dt.GetAsTimestamp(0) loo_Bd.AppendString(ls_Created,"utf-8") // This example wishes to calculate a password digest like this: // Password_Digest = Base64 ( SHA-1 ( nonce + created + SHA-1(password) ) ) // First SHA-1 digest the password... ls_PasswordSha1 = loo_Crypt.HashStringENC(ls_Password) // Append the 20 binary bytes of the SHA1 hash to bd, which already contains the nonce and created date/time. loo_Bd.AppendEncoded(ls_PasswordSha1,"base64") ls_PasswordDigest = loo_Crypt.HashBdENC(loo_Bd) Write-Debug "Base64 password digest = " + ls_PasswordDigest destroy loo_Crypt destroy loo_Prng destroy loo_Bd destroy loo_Dt |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.