Class DSHA256

Inherits from:
Object
Declared in:
DSHA256.h

Class Hierarchy

    Object
      |
      +---DSHA256

Class Description

The DSHA256 class implements a number of methods for using the NIST's SHA256 algorithm.

Example:
#include <stdio.h>
#include "ofc/DSHA256.h"

int main(int argc, char *argv[])
{
  DSHA256 *sha1 = [DSHA256 alloc];
  DSHA256 *sha2 = [DSHA256 new  ];
  DText   *str;
  DData   *data;

  [sha1 init :"This is a test string for SHA256"]; // Init with a test string

  str = [sha1 hexdigest];              // Convert sha256 value to hexstring
  printf("SHA256 of \"This is a test string for SHA256\" in hex-string is:%s.\n", [str cstring]);
  [str free];


  [sha2 update :"abcdefghijklmnopqrstuvwxyz"]; // Feed the sha2 variable with a c-string
  [sha2 update :"0123456789" :10];     // Feed the sha2 variable with data string

  data = [sha2 digest];
  str  = [data toBase64];              // Get SHA256 value and convert to base 64
  printf("SHA256 of test string in base64 is:%s.\n", [str cstring]);
  [str  free];
  [data free];

  [sha1 free];                         // Cleanup
  [sha2 free];

  return 0;
}
Last modified:
02-Aug-2008 (DSHA256.h)

Instance Variables

private uint32_t _h[8]
private uint32_t _count[2]
private unsigned char _input[64]

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0