Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

SHA-1 Hash Byte Array

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries

This sample program demonstrates how to SHA-1 hash a byte array.

// The Chilkat Encryption library is also available as an ActiveX component
// or .NET class with the identical set of methods and properties.

// SHA-1 Hash Byte Array
void CryptExample(void)
    {
    CkCrypt2 crypt;
    
    // Any string passed to UnlockComponent automatically begins the 30-day trial.
    crypt.UnlockComponent("30-day trial");

    // Use the SHA-1 hash algorithm.
    // Other hash algorithms: md5, md2, sha-1 (sha-256), sha-384, sha-512
    crypt.put_HashAlgorithm("sha1");
    
    // Create some data to hash.
    int i;
    unsigned char dataToHash[50];
    for (i=0; i<50; i++) dataToHash[i] = i;

    // Hash the byte array
    CkByteData hash;
    CkByteData inData;
    // Borrow the data so we don't need an extra memcpy
    inData.borrowData(dataToHash,50);
    crypt.HashBytes(inData,hash);

    printf("hash size = %d bytes\n",hash.getSize());

    // Display the hash.
    CkString strTemp;
    strTemp.appendHexData(hash.getData(),hash.getSize());
    printf("%s\n",strTemp.getString());

    // PRINTS:
    // hash size = 20 bytes
    // 0BD9 8598 F9AB 29C1 359E F546 0A20 6DD1 
    // 3705 15E3 

 

 

 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser