Results 1 to 40 of 81

Thread: [VB6] HMAC-SHA-256, HMAC-SHA-1 Using Crypto API

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    [VB6] HMAC-SHA-256, HMAC-SHA-1 Using Crypto API

    Title

    HS256, a class for calculating HMAC-SHA-256 from a Key and Data in VB6.

    note:

    HS1 (HMAC-SHA-1) also included now. Scroll down to the latest versions of both!

    Description

    The HS256 class uses Windows Crypto API calls wherever possible to calculate HMACs (Hash-based Message Authentication Codes) based on SHA 256 hashes. The class also provides formatting functions between binary data and Strings (Base64, Hex, and Hex variations) as well as converting Strings to and from UTF8 encoding.

    All of these things are useful in creating message authentication strings for many purposes. These HMACs are needed in message authentication for the SOAP and REST APIs provided by many cloud computing services. They are also sometimes used to sign other types of messages (e.g. email).

    Feature list
    • HMAC-SHA-256 calculation without the use of any external cryptography components, relies on the Windows Crypto API.
    • Translation of binary data to and from Base64 strings.
    • Translation of binary data to and from Hex strings (several variations such as Hex with address and ASCII).
    • Translation of standard "Unicode" (UTF16-LE) String data to and from UTF8 encoding.

    Screenshot

    Screenshot of the (attached) demo shown below.

    Author name

    Bob Riemersma

    System requirements

    Requires Windows XP or later. May require XP SP1 or SP2 (Crypto API documentation is not explicit on this point). Some minor format variations are emulated under Windows XP instead being performed via Crypto API calls, one minor sub-variation is only available in Windows 2003 R2, Vista, or later.

    No special processor, disk, or memory requirements. Requires Visual Basic 6.0 development system, preferably Service Pack 6b or later, Standard Edition or better.

    License info

    This software is released into the Public Domain. It may be used for any purpose as is or in derivative works. No warranty of fitness or merchantability, and no support is offered. This source code is available AS IS.

    Usage

    Add the class module to your VB6 project. See comments at the head of the source regarding use of the methods and properties provided.

    The demonstration project

    The HS256 class is posted here as part of a demo program.

    This program demonstrates the 7 SHA-256 Test Case vector sets found in RFC 4231:

    Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256,
    HMAC-SHA-384, and HMAC-SHA-512
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by dilettante; Apr 16th, 2011 at 09:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width