Ejemplo n.º 1
0
TEST(UtilitiesTest, testHMAC01) {
    //This test case is an official one from an RFC.
    uint8_t key[64];
    convertFromHex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", key, 20);
    uint8_t data[64];
    convertFromHex("4869205468657265", data, 8);

    uint8_t digest[32];

    HMAC_SHA256_Buf(key, 20, data, 8, digest);

    EXPECT_EQ(std::string("b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"), std::string(Hex(digest, 32)));
}
Ejemplo n.º 2
0
void cColor::HexToSDLColor( std::string HexColor, SDL_Color* SDLColor )
{
    int offset = ( HexColor.substr( 0, 1 ) == "#" ) ? 1 : 0;
    
    //int x = HexColor.length();
    if( HexColor.length() < 6 || HexColor.length() > 7 )
    {
        // not a valid RGB hex value
        SDLColor->r = 0;
        SDLColor->g = 0;
        SDLColor->b = 0;
        g_LogFile.ss() << "Error, provided string '" << HexColor << "' is not a valid RGB hex value" << std::endl;
        g_LogFile.ssend();
        return;
    }
    
    std::string redString = HexColor.substr( 0 + offset, 2 );
    std::string greenString = HexColor.substr( 2 + offset, 2 );
    std::string blueString = HexColor.substr( 4 + offset, 2 );
    
    SDLColor->r = convertFromHex( redString );
    SDLColor->g = convertFromHex( greenString );
    SDLColor->b = convertFromHex( blueString );
}