sha1str.cpp revision c7814cf6e1240a519cbec0441e033d0e2470ed00
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/* $Id$ */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/** @file
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * IPRT - SHA-1 string functions.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/*
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Copyright (C) 2009-2010 Oracle Corporation
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * This file is part of VirtualBox Open Source Edition (OSE), as
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * available from http://www.virtualbox.org. This file is free software;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * you can redistribute it and/or modify it under the terms of the GNU
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * General Public License (GPL) as published by the Free Software
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Foundation, in version 2 as it comes in the "COPYING" file of the
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * The contents of this file may alternatively be used under the terms
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * of the Common Development and Distribution License Version 1.0
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * VirtualBox OSE distribution, in which case the provisions of the
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * CDDL are applicable instead of those of the GPL.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * You may elect to license modified versions of this file under the
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * terms and conditions of either the GPL or the CDDL or both.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/*******************************************************************************
1e83c8de3aa48b316b28057d53995272baf1260cwrowe* Header Files *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe*******************************************************************************/
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#include "internal/iprt.h"
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#include <iprt/sha.h>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#include <iprt/assert.h>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#include <iprt/err.h>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#include <iprt/string.h>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwroweRTDECL(int) RTSha1ToString(uint8_t const pabDigest[RTSHA1_HASH_SIZE], char *pszDigest, size_t cchDigest)
1e83c8de3aa48b316b28057d53995272baf1260cwrowe{
1e83c8de3aa48b316b28057d53995272baf1260cwrowe return RTStrPrintHexBytes(pszDigest, cchDigest, &pabDigest[0], RTSHA1_HASH_SIZE, 0 /*fFlags*/);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe}
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwroweRTDECL(int) RTSha1FromString(char const *pszDigest, uint8_t pabDigest[RTSHA1_HASH_SIZE])
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe{
1e83c8de3aa48b316b28057d53995272baf1260cwrowe return RTStrConvertHexBytes(RTStrStripL(pszDigest), &pabDigest[0], RTSHA1_HASH_SIZE, 0 /*fFlags*/);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe}
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe