コード例 #1
0
ファイル: encrypt.cpp プロジェクト: PotcFdk/AESthetic
void AES::encrypt()
{
    round = 0;

    keyAdd();
    round++;

    for (; round < 10; round++)
        runRound();

    subBytes();
    shiftRows();
    keyAdd();

    printData();
}
コード例 #2
0
ファイル: encrypt.cpp プロジェクト: PotcFdk/AESthetic
void AES::verboseEncryptNoReset()
{
    if (round == 0)
    {
        std::cout << "Round " << round << " plaintext:" << std::endl;
        printData();

        keyAdd();

        std::cout << std::endl << "Round " << round << " keyAdd:" << std::endl;
        printData();

        round++;
    }

    for (; round < 10; round++)
    {
        std::cout << std::endl << "Round " << round << " plaintext:" << std::endl;
        printData();
        subBytes();
        std::cout << std::endl << "Round " << round << " subBytes:" << std::endl;
        printData();
        shiftRows();
        std::cout << std::endl << "Round " << round << " shiftRows:" << std::endl;
        printData();
        mixColumns();
        std::cout << std::endl << "Round " << round << " mixColumns:" << std::endl;
        printData();
        keyAdd();
        std::cout << std::endl << "Round " << round << " keyAdd:" << std::endl;
        printData();
    }

    subBytes();
    std::cout << std::endl << "Round " << round << " subBytes:" << std::endl;
    printData();
    shiftRows();
    std::cout << std::endl << "Round " << round << " shiftRows:" << std::endl;
    printData();
    keyAdd();
    std::cout << std::endl << "Round " << round << " keyAdd / ciphertext:" << std::endl;
    printData();
}
コード例 #3
0
ファイル: vector.c プロジェクト: iloveloveyou/chirico
int main(void)
{
    Key_val *k = NULL;
    Vec *v = NULL;
    char *s;
    char ts[] = "one";
    int i = 0;

    k = keyAdd(k, ts, "1");
    k = keyAdd(k, "two", "2");
    k = keyAdd(k, "three", "3");
    k = keyAdd(k, "four", "4");
    k = keyAdd(k, "five", "5");
    v = vecAdd(v, "ONE", k);
    //This doesn_t have to be last but k
    // must have a value. So it can_t go first.

	// You need to reset k
	k = NULL;
    k = keyAdd(k, "twenty one", "21");
    k = keyAdd(k, "twenty two", "22");
    k = keyAdd(k, "twenty three", "23");
    k = keyAdd(k, "twenty four", "24");
    v = vecAdd(v, "TWO", k);

    prV(v);

    printf("\n\n ................ \n\n");

    //Example returning key_val from the string found in vector v
	printf("Below pr(findK(v,\"ONE\"))\n");
    pr(findK(v, "ONE"));

    printf("Below pr(findK(v,\"TWO\"))\n");
    pr(findK(v, "TWO"));



    printf("\n");
    s = (char *)malloc(sizeof(char) * 80);
    strcpy(s, "twenty two");
    fprintf(stderr, "find(c,%s)=%s\n", s, find(k, s));
    modify(k,s,"New twenty two");

    k = findK(v, "ONE");
    strcpy(s, "one");
    fprintf(stderr, "find(c,%s)=%s\n", s, find(k, s));
    free(s);

    printf("\n\nExample use in a for loop.\n\n");
    for (i = 0; i < pvLength(v); ++i) {
	pr(getK(v, i));
	printf("......\n");

    }

    myfreeV(v);
    //Note myfreeV calls this
	// myfree(k);

    return 0;
}
コード例 #4
0
void CalculatorTestApp::handleKey(widgetid_t keyPressed) {

//  keyMap origKeyMap = (keyMap)buttons->getMap();

  switch (keyPressed) {
    case zero:
    case one:
    case two:
    case three:
    case four:
    case five:
    case six:
    case seven:
    case eight:
    case nine:
    case hex_a:
    case hex_b:
    case hex_c:
    case hex_d:
    case hex_e:
    case hex_f:
      keyDigit(keyPressed);
      break;
    case decimal:
      keyDecimal();
      break;
    case enter:
      keyEnter();
      break;
    case clear:
      keyClear();
      break;
    case backspace:
      keyBackspace();
      break;
    case shift:
      keyShift();
      break;
    case ee:
      keyEE();
      break;
    default:
      // the following are functions that accept the current input string
      acceptText();
      switch (keyPressed) {
      case divide:
        keyDivide();
        break;
      case multiply:
        keyMultiply();
        break;
      case add:
        keyAdd();
        break;
      case subtract:
        keySubtract();
        break;
      case inverse:
        keyInverse();
        break;
      case percent:
        keyPercent();
        break;
      case swap:
        keySwap();
        break;
      case changeBase:
        keyBase();
        break;
      case send:
        keySend();
        break;
      case square_f:
        keySquare();
        break;
      case cube_f:
        keyCube();
        break;
      case pow_f:
        keyPow();
        break;
      case exp_f:
        keyExp();
        break;
      case pow10_f:
        keyPow10();
        break;
      case sqrt_f:
        keySqrt();
        break;
      case cubert_f:
        keyCubert();
        break;
      case xroot_f:
        keyXroot();
        break;
      case ln_f:
        keyLn();
        break;
      case log10_f:
        keyLog10();
        break;
      case sin_f:
        keySin();
        break;
      case cos_f:
        keyCos();
        break;
      case tan_f:
        keyTan();
        break;
      case pi_f:
        keyPi();
        break;
      case e_f:
        keyE();
        break;
      case asin_f:
        keyAsin();
        break;
      case acos_f:
        keyAcos();
        break;
      case atan_f:
        keyAtan();
        break;
      case logy_f:
        keyLogy();
        break;
      case log2_f:
        keyLog2();
        break;
      case in2mm_f:
        keyIn2mm();
        break;
      case mm2in_f:
        keyMm2In();
        break;
      case g2lb_f:
        keyG2lb();
        break;
      case lb2g_f:
        keyLb2g();
        break;
      case c2f_f:
        keyC2f();
        break;
      case f2c_f:
        keyF2c();
        break;
      case ppi_f:
        keyPpi();
        break;
      default:
        break;
    }
  }

//  if (origKeyMap == sci_map && buttons->getMap() == sci_map) {
//    buttons->setMap(basic_map);
//  }

  drawDisplay();
}