Exemple #1
0
Status
JsonBox::encrypt(DataSlice data, DataSlice key)
{
    DataChunk nonce;
    AutoU08Buf cyphertext;
    ABC_CHECK_OLD(ABC_CryptoEncryptAES256Package(data, key,
                  &cyphertext, nonce, &error));

    ABC_CHECK(typeSet(AES256_CBC_AIRBITZ));
    ABC_CHECK(nonceSet(base16Encode(nonce)));
    ABC_CHECK(cyphertextSet(base64Encode(cyphertext)));

    return Status();
}
Exemple #2
0
int ex_send_msg(ExHttp *pHttp, const char *type, const char *buf, size_t len)
{
  char hBuf[BUFSIZ] ;
  char *pBuf = hBuf ;
  int ret ;
  pBuf += codeSet( pBuf, 200 ) ;
  pBuf += typeSet( pBuf, type ) ;
  pBuf += lengthSet( pBuf, len ) ;

  do {
    if ( (ret = sendHead( pHttp, hBuf, pBuf-hBuf ))<0 )
      break ;
    if ( (ret = ex_sock_nwrite( pHttp->sock, ( char * ) buf, len ))<0 )
      break ;
  } while ( 0 ) ;
  return ret ;
}