コード例 #1
0
ファイル: xyssl.cpp プロジェクト: Redi0/jucpp
	uint Sha::GetFileDigest(void* digest, LPCSTR fn, SHA_BITS bits) {
		int rst;
		if(bits == sha_160) {
			rst = sha1_file((char*)fn, (byte*)digest);
		} else if(bits == sha_224) {
			rst = sha2_file((char*)fn, (byte*)digest, 1);
		} else if(bits == sha_256) {
			rst = sha2_file((char*)fn, (byte*)digest, 0);
		} else if(bits == sha_384) {
			rst = sha4_file((char*)fn, (byte*)digest, 1);
		} else if(bits == sha_512) {
			rst = sha4_file((char*)fn, (byte*)digest, 0);
		} else {
			_ASSERT(0);
			return 0;
		}
		return rst ? 0 : bits;
	}
コード例 #2
0
ファイル: md_wrap.c プロジェクト: 451506709/automated_machine
int sha256_file_wrap( const char *path, unsigned char *output )
{
#if defined(POLARSSL_FS_IO)
    return sha2_file( path, output, 0 );
#else
    ((void) path);
    ((void) output);
    return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
#endif
}
コード例 #3
0
static int sha2_wrapper( char *filename, unsigned char *sum )
{
    int ret = sha2_file( filename, sum, 0 );

    if( ret == 1 )
        fprintf( stderr, "failed to open: %s\n", filename );

    if( ret == 2 )
        fprintf( stderr, "failed to read: %s\n", filename );

    return( ret );
}
コード例 #4
0
ファイル: util.c プロジェクト: sandsmark/pacman
/** Get the sha256 sum of file.
 * @param filename name of the file
 * @return the checksum on success, NULL on error
 * @addtogroup alpm_misc
 */
char SYMEXPORT *alpm_compute_sha256sum(const char *filename)
{
	unsigned char output[32];

	ASSERT(filename != NULL, return NULL);

	/* defined above for OpenSSL, otherwise defined in sha2.h */
	if(sha2_file(filename, output, 0) > 0) {
		return NULL;
	}

	return hex_representation(output, 32);
}
コード例 #5
0
ファイル: xyssl.cpp プロジェクト: Redi0/jucpp
	uint Sha::GetFileDigest(void* digest,LPCWSTR fn,SHA_BITS bits){
		String str = fn;
		char buf[MAX_PATH];
		int len = str.ToMultiByte(buf,MAX_PATH,CP_THREAD_ACP);
		buf[len] = 0;
		int rst;
		if(bits==sha_160){
			rst = sha1_file(buf,(byte*)digest);
		}else if(bits==sha_224){
			rst = sha2_file(buf,(byte*)digest,1);
		}else if(bits==sha_256){
			rst = sha2_file(buf,(byte*)digest,0);
		}else if(bits==sha_384){
			rst = sha4_file(buf,(byte*)digest,1);
		}else if(bits==sha_512){
			rst = sha4_file(buf,(byte*)digest,0);
		}else{
			_ASSERT(0);
			return 0;
		} 
		return rst?0:bits;
	}