求一个AES加密类  封装好的那种, 最好带个例子,我在CSDN下载了 100多个 没有一个我能看懂的,150分都用光了,搞了二天了 要死人了, 我是VS2010  .各位谁有自己用的AES加密类 发我一份吧, 。一定要说明 调用方法 有例子。谢谢。   我找了一个封装好的类,可是不会用, 下载地址  http://download.csdn.net/detail/xieaqiang/3917787   下载不用分。  你看看,里面只有3个方法,如果你会用做个例子 回复我吧, 求命啊, 感谢了。搞的我身心疲惫。 感谢。

解决方案 »

  1.   


    /*
     *  This program demonstrates how to use AES to encrypt/decrypt a 
     *    block (128 bits) of data. To encrypt/decrypt data that are
     *    larger than one block, you need to implement one of the modes of 
     *    AES, such as AES-ECB and AES-CBC.  
     */#include "aes.h"#include <string.h>
    #include <stdio.h>static unsigned char AES_test[16] =
    { 0xF5, 0xBF, 0x8B, 0x37, 0x13, 0x6F, 0x2E, 0x1F,
      0x6B, 0xEC, 0x6F, 0x57, 0x20, 0x21, 0xE3, 0xBA 
    };static unsigned char secret_key[32] =

        0x4E, 0x46, 0xF8, 0xC5, 0x09, 0x2B, 0x29, 0xE2,
        0x9A, 0x97, 0x1A, 0x0C, 0xD1, 0xF6, 0x10, 0xFB,
        0x1F, 0x67, 0x63, 0xDF, 0x80, 0x7A, 0x7E, 0x70,
        0x96, 0x0D, 0x4C, 0xD3, 0x11, 0x8E, 0x60, 0x1A 
    };    
    int main( void )
    {
        int n, i;
        aes_context ctx;
        unsigned char buf[16];
        unsigned char key[32];    /* Keys can be 128 bits, 192 bits, and 256 bits  */
        for (n = 0; n < 3; n++)
        {
           printf("\n-------------------------------------------------\n");
           printf( "Test %d: key size = %3d bits\n", n, 128 + n * 64 );       fflush( stdout );       /* Set the plain-text */
           memcpy( buf, AES_test, 16);        /* Set the key */
           memcpy( key, secret_key, 16 + n * 8);
           aes_set_key( &ctx, key, 128 + n * 64);       /* Print out the plain text */
           for (i = 0; i< 16; i++) {
             printf("%2x ", buf[i]); 
           }
           printf(" (Plain Text)\n");       aes_encrypt( &ctx, buf, buf );
           for (i = 0; i< 16; i++) {
             printf("%2x ", buf[i]); 
           } 
           printf(" (Cipher Text)\n");       
           aes_decrypt( &ctx, buf, buf );
           for (i = 0; i< 16; i++) {
             printf("%2x ", buf[i]); 
           }  
           printf(" (Decrypted Plain Text)\n");
        }
                
        return( 0 );
    }使用例子 自己用的话 循环加密就好,1次加密16个字节.支持128,196,256位
      

  2.   


    #ifndef _AES_H
    #define _AES_H#ifndef uint8
    #define uint8  unsigned char
    #endif#ifndef uint32
    #define uint32 unsigned long int
    #endiftypedef struct
    {
        uint32 erk[64];     /* encryption round keys */
        uint32 drk[64];     /* decryption round keys */
        int nr;             /* number of rounds */
    }
    aes_context;int  aes_set_key( aes_context *ctx, uint8 *key, int nbits );
    void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
    void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );#endif /* aes.h */这是AES.h
      

  3.   

    .c 内容太长了...发不上来 或则你自己去OpenSSl里面挖出来吧....
      

  4.   

    http://wenku.baidu.com/view/2dadea1655270722192ef7af.html
      

  5.   

    http://www.cnblogs.com/mingcn/archive/2011/11/25/1865447.html
      

  6.   

    干吗要看懂算法呢?给你提供一组例子,只要你用算法算出来的结果跟这个相同,就算对了。
    //
    aes128_encode_ecb ( 1122334455667788 1122334455667788 , 1122334455667788 4422551133669977 9977225599774400 1133557799442288 ) 
    //--
    aes 128 ecb encrypt
    //--
    key = 11 22 33 44 55 66 77 88 44 22 55 11 33 66 99 77 
    //--
    plain = 11 22 33 44 55 66 77 88 11 22 33 44 55 66 77 88   cipher = 17 AA 5C 86 24 39 88 5E 57 26 01 42 FB D6 DC 44 
    //

    //-----
    最终计算结果 --- 17 AA 5C 86 24 39 88 5E 57 26 01 42 FB D6 DC 44 
    //

    //
    aes192_encode_ecb ( 1122334455667788 1122334455667788 , 1122334455667788 4422551133669977 9977225599774400 1133557799442288 ) 
    //--
    aes 192 ecb encrypt
    //--
    key = 11 22 33 44 55 66 77 88 44 22 55 11 33 66 99 77 99 77 22 55 99 77 44 00 
    //--
    plain = 11 22 33 44 55 66 77 88 11 22 33 44 55 66 77 88   cipher = DC 8F DE B3 4B E3 F5 AD 05 5D 20 95 50 D0 D9 BA 
    //

    //-----
    最终计算结果 --- DC 8F DE B3 4B E3 F5 AD 05 5D 20 95 50 D0 D9 BA 
    //

    //
    aes256_encode_ecb ( 1122334455667788 1122334455667788 , 1122334455667788 4422551133669977 9977225599774400 1133557799442288 ) 
    //--
    aes 256 ecb encrypt
    //--
    key = 11 22 33 44 55 66 77 88 44 22 55 11 33 66 99 77 99 77 22 55 99 77 44 00 11 33 55 77 99 44 22 88 
    //--
    plain = 11 22 33 44 55 66 77 88 11 22 33 44 55 66 77 88   cipher = F3 50 2A 0C AB 6E E3 E3 02 C4 C6 DA 0D 73 F5 27 
    //

    //-----
    最终计算结果 --- F3 50 2A 0C AB 6E E3 E3 02 C4 C6 DA 0D 73 F5 27 
    //