Thread: How do i un-SHA1 hash something..

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    How do i un-SHA1 hash something..

    hey, i'm using CryptoSys API for encryption, and i got a program to successfully encrypt using the SHA1 algorithm....but how do i un-SHA1 the information? lol

    thanks
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    define:hash

    - A mathematical formula that converts a message of any length into a unique fixed-length string of digits (typically 160 bits) known as "message digest" that represents the original message. A hash is a one-way function - that is, it is infeasible to reverse the process to determine the original message. Also, a hash function will not produce the same message digest from two different inputs.

    - A one-way algorithm which maps or translates one set of bits into another (generally smaller) in such a way that the algorithm yields the same hash results every time for the same message, and it is computationally infeasible for a message to be reconstituted from the hash result. Also, two different messages cannot produce the same hash results.

    You can't! You don't! If you want to be able to recover your plaintext, use an encryption algorithm, not a hashing algorithm.

  3. #3
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    hahah.

    good point... :-[

    liiiiike..?

    mm..however much names of encryption algorithms help...they dont, tutorials / source help. thanks!


    mm..in case it matters: OS - Windows XP Pro SP2
    Dev-C++ 4.9.9.2
    Registered Linux User #380033. Be counted: http://counter.li.org

  4. #4
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    AES?

  5. #5
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    hMm....not to be a [Shift]+244, but..
    mm..however much names of encryption algorithms help...they dont, tutorials / source help. thanks!

    i know OF encryption methods such as AES, its predecessor DES, blowfish.....but i dont know how to use them. i even have the prototypes defined in the diCryptoSys.h header file..
    Code:
    /* AES-256 PROTOTYPES */
    long _stdcall AES256_Bytes(unsigned char *output, const unsigned char *input,
    	long nbytes, const unsigned char *key, int bEncrypt); 
    long _stdcall AES256_BytesMode(unsigned char *output, const unsigned char *input,
    	long nbytes, const unsigned char *key, int bEncrypt, 
    	const char *lpszMode, const unsigned char *iv);
    long _stdcall AES256_Hex(char *lpszOutput, const char *lpszInput,
    	const char *lpszKey, int bEncrypt);
    long _stdcall AES256_HexMode(char *lpszOutput, const char *lpszInput,
    	const char *lpszKey, int bEncrypt, const char *lpszMode, const char *lpszIV);
    long _stdcall AES256_File(const char *lpszFileOut, const char *lpszFileIn,
    	const unsigned char *key, int bEncrypt, const char *lpszMode, const unsigned char *iv);
    long _stdcall AES256_FileHex(const char *lpszFileOut, const char *lpszFileIn,
    	const char *lpszKey, int bEncrypt, const char *lpszMode, const char *lpszIV);
    long _stdcall AES256_Init(const unsigned char *key,  
    	int bEncrypt, const char *lpszMode, const unsigned char *iv);
    long _stdcall AES256_InitHex(const char *lpszKey, int bEncrypt, 
    						   const char *lpszMode, const char *lpszIV);
    long _stdcall AES256_Update(long ctx_handle, unsigned char *data, long dataLen);
    long _stdcall AES256_UpdateHex(long ctx_handle, char *lpszHex);
    long _stdcall AES256_Final(long ctx_handle);
    long _stdcall AES256_InitError(void);
    
    /* BLOWFISH PROTOTYPES */
    long _stdcall BLF_Hex(char *sOutput, const char *sInput,
    	const char *sKey, int bEncrypt);
    long _stdcall BLF_HexMode(char *sOutput, const char *sInput,
    	const char *sHexKey, int bEncrypt, const char *sMode, const char *sHexIV);
    long _stdcall BLF_Bytes(unsigned char *output, const unsigned char *input,
    	long nbytes, const unsigned char *key, long keyBytes, int bEncrypt);
    long _stdcall BLF_BytesMode(unsigned char *output, const unsigned char *input,
    	long nbytes, const unsigned char *key, long keyBytes, 
    	int bEncrypt, const char *sMode, const unsigned char *iv);
    long _stdcall BLF_File(const char *sFileOut, const char *sFileIn,
    	const unsigned char *key, long keyBytes, int bEncrypt,
    	const char *sMode, const unsigned char *iv);
    long _stdcall BLF_FileHex(const char *sFileOut, const char *sFileIn,
    	const char *sHexKey, int bEncrypt, const char *sMode, const char *sHexIV);
    long _stdcall BLF_Init(const unsigned char *key, 
    	long keyBytes, int bEncrypt,
    	const char *sMode, const unsigned char *iv);
    long _stdcall BLF_InitHex(const char *sHexKey, int bEncrypt,
    	const char *sMode, const char *sHexIV);
    long _stdcall BLF_UpdateHex(long ctx_handle, char *sHexData);
    long _stdcall BLF_Update(long ctx_handle, unsigned char *data,
    						   long dataLen);
    long _stdcall BLF_Final(long ctx_handle);
    long _stdcall BLF_Ecb(long ctx_handle, unsigned char *data,
    						   long dataLen, int bEncrypt);
    long _stdcall BLF_EcbHex(long ctx_handle, char *sHexBlock, int bEncrypt);
    long _stdcall BLF_InitError(void);
    and i could take a stab at implementing them, but i'd prly be wrong. lol
    thanks tho

    also..for SHA1 i had declared char digest[41]; to hold the hashed string..if i were going to use SHA-256..whats size of an array would i have to declare? char digest[64]?
    thanks^3, lol
    Last edited by willc0de4food; 09-14-2005 at 06:36 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with unaligned intrinsics
    By The Wazaa in forum C++ Programming
    Replies: 4
    Last Post: 02-18-2009, 12:36 PM
  2. Bernstein hash?
    By audinue in forum C Programming
    Replies: 0
    Last Post: 01-07-2009, 07:24 AM
  3. need help with hash tables with direct chaining
    By agentsmith in forum C Programming
    Replies: 4
    Last Post: 01-05-2008, 04:19 AM
  4. Group Project Help/Volunteer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2007, 11:36 PM
  5. Not sure on hash table memory allocations
    By Thumper333 in forum C Programming
    Replies: 3
    Last Post: 09-27-2004, 09:00 PM