诸暨麻将添加redis
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

69 řádky
1.6 KiB

  1. //AES.h
  2. #ifndef _AES_H
  3. #define _AES_H
  4. #include <exception>
  5. #include <cstring>
  6. #include <string>
  7. #define BLOCK_SIZE 16
  8. using namespace std;
  9. class AES
  10. {
  11. public:
  12. enum
  13. {
  14. ECB = 0, CBC = 1, CFB = 2
  15. };
  16. private:
  17. enum
  18. {
  19. DEFAULT_BLOCK_SIZE = 16
  20. };
  21. enum
  22. {
  23. MAX_BLOCK_SIZE = 32, MAX_ROUNDS = 14, MAX_KC = 8, MAX_BC = 8
  24. };
  25. public:
  26. AES();
  27. virtual ~AES();
  28. private:
  29. //Key Initialization Flag
  30. bool m_bKeyInit;
  31. //Encryption (m_Ke) round key
  32. int m_Ke[MAX_ROUNDS + 1][MAX_BC];
  33. //Decryption (m_Kd) round key
  34. int m_Kd[MAX_ROUNDS + 1][MAX_BC];
  35. //Key Length
  36. int m_keylength;
  37. //Block Size
  38. int m_blockSize;
  39. //Number of Rounds
  40. int m_iROUNDS;
  41. //Chain Block
  42. char m_chain0[MAX_BLOCK_SIZE];
  43. char m_chain[MAX_BLOCK_SIZE];
  44. //Auxiliary private use buffers
  45. int tk[MAX_KC];
  46. int a[MAX_BC];
  47. int t[MAX_BC];
  48. private:
  49. void Xor(char* buff, char const* chain);
  50. void DefEncryptBlock(char const* in, char* result);
  51. void DefDecryptBlock(char const* in, char* result);
  52. void EncryptBlock(char const* in, char* result);
  53. void DecryptBlock(char const* in, char* result);
  54. public:
  55. void MakeKey(char const* key, char const* chain, int keylength =
  56. DEFAULT_BLOCK_SIZE, int blockSize = DEFAULT_BLOCK_SIZE);
  57. void Encrypt(char const* in, char* result, size_t n, int iMode = ECB);
  58. void Decrypt(char const* in, char* result, size_t n, int iMode = ECB);
  59. };
  60. #endif // __RIJNDAEL_H__
  61. //-------------------- -
  62. //作者:hailyluo
  63. //来源:CSDN
  64. //原文:https ://blog.csdn.net/csdn49532/article/details/50686222
  65. //版权声明:本文为博主原创文章,转载请附上博文链接!